[Tutor] Help with Elementtree ...how to access the attributes..

Asrarahmed Kadri ajkadri at googlemail.com
Thu Nov 9 19:23:50 CET 2006


Hi Folks,


I am trying to parse XML documents using elementtree.
I have just started with it. Can somebody help me with how to select nodes
with a particular atribute set to some value. For example, I have the
following file. Now I want to access the founder element of the company
whose attribute is set to 'ndtv'. Can somebody help me with this?

sample.xml


<info>
<company name = 'google'>
 <founder> <one> larry page </one>
 <two> sergey brin</two>
 </founder>
 <focus> search engine </focus>

</company>

<company name = 'ndtv'>
<founder> <one>Pranoy Roy </one>
 <two> Radhika Roy</two>
</founder>
<focus> news </focus>
</company>

<company  name = "wipro">
<founder> Azeem Premje </founder>
<focus> IT services </focus>
</company>
</info>

-- 
To HIM you shall return.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061109/e6c324aa/attachment.htm 


More information about the Tutor mailing list