I'm using minidom for read XML document. I need find the "Member" tag name and if the attributes start with "W" or "F" I need read the text between "MultilanguajeTex" tag name.
It's possible?
I try this:
mydoc = minidom.parse('DB.xml')
items = mydoc.getElementsByTagName('Member')
for elem in items:
valor = elem.attributes['Name'].value
if (valor[0] == "F" or valor[0] == "W") and len(valor)<4:
print(len(valor))
print(valor)
texto = elem.SelectNodes('MultiLanguageText')
print(texto.localName)
XML text:
<Member Name="F00" Datatype="Bool">
<Comment>
<MultiLanguageText Lang="en-GB">
BottomSidePanels_Feeding_Zone_41 Fa 00. Material Jam. Material too much time going out Fw
</MultiLanguageText>
</Comment>
Thanks!
Using minidom it could be done as follows:
A bit simpler it could be achieved using lxml as it allows usage of XPath expressions: