I am trying to parse the following XML node using Python's minidom
.
<!-- Mapping of subjects -->
<root>
<English>
<key name = "Eng"></key>
</English>
<Maths>
<key name = "Mathematics"></key>
</Maths>
<SocialScience>
<key name = "Social"></key>
<key name = "Scocial"></key>
</SocialScience>
<NameoftheStudent>
<key name="Student's Name"></key>
<key name = "StudentName"></key>
</NameoftheStudent>
</root>
Following is the code for processing above XML:
xmldoc = minidom.parse('./templates/dictionary.xml')
root = xmldoc.getElementsByTagName('root')
for nodes in root:
for node in nodes.childNodes:
for x in node.childNodes:
print "hello"
What I have realized is that whenever I am retrieving child nodes, it is giving me one extra child node.