Adrocks__ Adrocks__ - 7 months ago 58
Python Question

Python XML parse issues

Currently trying to parse some XML using python, so far I've managed to get the name of the tag however I can't figure out how to get the data from inside this.

<Fragment name="Located At">Sector 121212</Fragment>

The above is an example of the XML file, I can get the "Located At" part out but not the "Sector 165658" I am currently using the following:

xmldoc = minidom.parse('file.xml')
itemlist = xmldoc.getElementsByTagName('Fragment')
for items in itemlist:
print (items.attributes['name'].value)

I can't for the life of me remember that the "name" for the section is I feel like this is going to be a simple answer and I'm going to look like an idiot but we shall see.

kfb kfb

According to the minidom docs, it looks like .childNodes might be the thing you're looking for.