I have the following XML file to read with Python:
<?xml version="1.0" encoding="UTF-8" standalone="true"?>
<!DOCTYPE boost_serialization>
<boost_serialization version="9" signature="serialization::archive">
<obj>
<count>2</count>
<item_version>0</item_version>
<item>3.1400001</item>
<item>7.3600001</item>
</obj>
</boost_serialization>
The python script I use to read this XML file is as follows:
from xml.dom import minidom
xmldoc = minidom.parse('items.xml')
itemlist = xmldoc.getElementsByTagName('item')
print(len(itemlist))
print(itemlist[0].attributes['ATTRIBUTE_NAME'].value)
The problem with the script is ATTRIBUTE_NAME does not exist. If I print it with print itemlist[0].attributes.keys()
, it is empty. So in this case how I can obtain the item values 3.1400001
and 7.3600001
?