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...

You can put in a few test prints (also use type()) to help you debug your code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.