When I execute the following code I get an error as 'NodeList' object has no attribute 'firstChild'.
from xml.dom import minidom
dat = minidom.parse('sample.xml')
tagname= dat.getElementsByTagName('item')
print(tagname.firstChild.data)
Here is my XML file:
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<food>
<item name="breakfast">Idly</item>
<price>$2.5</price>
<description>
Two idly's with chutney
</description>
<calories>553</calories>
</food></metadata>
What should I do?