I have an XML structure that looks like the following, but on a much larger scale:
<root>
<conference name='1'>
<author>Bob</author>
<author>Nigel</author>
</conference>
<conference name='2'>
<author>Alice</author>
<author>Mary</author>
</conference>
</root>
For this, I used the following code:
dom = parse(filepath)
conference=dom.getElementsByTagName('conference')
for node in conference:
conf_name=node.getAttribute('name')
print conf_name
alist=node.getElementsByTagName('author')
for a in alist:
authortext= a.nodeValue
print authortext
However, the authortext that is printed out is 'None.' I tried messing around with using variations like what is below, but it causes my program to break.
authortext=a[0].nodeValue
The correct output should be:
1
Bob
Nigel
2
Alice
Mary
But what I get is:
1
None
None
2
None
None
Any suggestions on how to tackle this problem?