XML : Case Insensitive XML parsing in Python Element Tree

I need to parse and get the specific attribute for the given attribute from the XML by using findall function in Element Tree lib. For Example,

  <Mapping>  <Map name="map1" sys_id="QAE567-hKLO890" path="\\sys1\map1\" uuid="EL8976-hF056" />  <Map name="map2" sys_id="RTY897-RT643DF" path="\\sys2\map2\" uuid="Jkl56W-yKP87" />  ...  ...  ...  </Mapping>    

We using following query to get the 'sys_id' and 'path' attribute for given uuid from the xml, but in some cases we are providing uuid with different case 'el8976-hf056' instead of 'EL8976-hF056'. In this case we are not able to get the path and sys_id of that uuid.

  Elms = root.findall(".//Mapping/Map[@uuid='%s']" % "el8976-hf056")    

How can we get the exact path and sys_id with correct case ?

No comments:

Post a Comment