![](https://secure.gravatar.com/avatar/839a034ca8c818d2689ad94c63a7aa0f.jpg?s=120&d=mm&r=g)
Hello, I have a xml file like this, http://msdn.microsoft.com/en-us/library/windows/desktop/ms762271(v=vs.85).as... Lets say I want to get all the book titles authored by, ¨O'Brien, Tim¨. What is the best way to do that?
![](https://secure.gravatar.com/avatar/1e2caa78f917e18fc081fed2f2058af7.jpg?s=120&d=mm&r=g)
Le 15/01/2012 16:27, Mag Gam a écrit :
Hello,
I have a xml file like this, http://msdn.microsoft.com/en-us/library/windows/desktop/ms762271(v=vs.85).as...
Lets say I want to get all the book titles authored by, ¨O'Brien, Tim¨. What is the best way to do that?
Hi, Have you looked at XPath? http://lxml.de/xpathxslt.html The link above is for the lxml API. There are many resources on the web for learning the XPath syntax. Your example would be something like this (untested) element_list = some_lxml_tree.xpath( '/book[author/text() = "O'Brien, Tim"]') Regards, -- Simon Sapin
![](https://secure.gravatar.com/avatar/839a034ca8c818d2689ad94c63a7aa0f.jpg?s=120&d=mm&r=g)
thankyou On Mon, Jan 16, 2012 at 3:03 AM, Simon Sapin <simon.sapin@kozea.fr> wrote:
Le 15/01/2012 16:27, Mag Gam a écrit :
Hello,
I have a xml file like this, http://msdn.microsoft.com/en-us/library/windows/desktop/ms762271(v=vs.85).as...
Lets say I want to get all the book titles authored by, ¨O'Brien, Tim¨. What is the best way to do that?
Hi,
Have you looked at XPath?
The link above is for the lxml API. There are many resources on the web for learning the XPath syntax. Your example would be something like this (untested)
element_list = some_lxml_tree.xpath( '/book[author/text() = "O'Brien, Tim"]')
Regards, -- Simon Sapin _________________________________________________________________ Mailing list for the lxml Python XML toolkit - http://lxml.de/ lxml@lxml.de https://mailman-mail5.webfaction.com/listinfo/lxml
participants (2)
-
Mag Gam
-
Simon Sapin