searching an XML doc

Stefan Behnel stefan.behnel-n05pAM at web.de
Wed Jan 16 15:12:32 EST 2008


grflanagan wrote:
> On Jan 15, 9:33 pm, Gowri <gowr... at gmail.com> wrote:
>> I've been reading about ElementTreee and ElementPath so I could use
>> them to find the right elements in the DOM. Unfortunately neither of
>> these seem to offer XPath like capabilities where I can find elements
>> based on tag, attribute values etc. Are there any libraries which can
>> give me XPath like functionality?
> 
> Create your query like:
> 
> ns0 = '{http://a.b.com/phedex}'
> 
> query = '%srequest/%sstatus' % (ns0, ns0)

lxml supports the same thing, BTW, and how to work with namespaces is
explained in the tutorial:

http://codespeak.net/lxml/dev/tutorial.html#namespaces

Stefan



More information about the Python-list mailing list