The following code parses the xml content and prints the attribute and text values
from xml.dom import minidom
xmldoc = minidom.parse('myitems.xml')
itemlist = xmldoc.getElementsByTagName('item')
# Get attribute value of <item> tag e.g.
for s in itemlist:
print("Attribute - ", s.attributes['name'].value)
# Get values in <item> tag
for s in itemlist:
print("Value - ", s.firstChild.nodeValue)
Attribute - item1
Attribute - item2
Attribute - item3
Attribute - item4
Value - East
Value - West
Value - North
Value - South
Comment here