hello sir,
i have a xml file like
<book>
<title>abc</title>
........
<details>
<name>abc</name>
.....
<author>shakespere</author>
<year>1980</year>
</details>
<details>
<name>xyz</name>
.....
<author>anand</author>
<year>1995</year>
</details>
</book>
i need to print the values of author,year if details.name == title
here is my code
DomTree = xml.dom.minidom.parse(file)
book = DomTree.documentElement
for t in domain.getElementsByTagName("title"):
title_name= t.childNodes[0].data
print "Title :", tile_name
for tname in domain.getElementsByTagName("details"):
aname= tname.getFirstChild().getNodeValue()
if (aname == title_name):
for aut in tname.getElementsByTagName("author"):
print "Author : ",aut.childNodes[0].data
for y in tname.getElementsByTagName("year"):
print "Year : ",y.childNodes[0].data
error:AttributeError: Element instance has no attribute 'getFirstChild'
please corrct my code to get the required output.
thanks in advance...