Re: [xml] xpathEval and namespaces

Daniel Veillard wrote:
On Tue, Sep 14, 2004 at 12:47:43PM +0200, Jos Vos wrote:

With this even docroot.xpathEval('/head') gives an empty nodeset back
(docroot is my root node object), while it works fine when I remove
the namespace attributes.

  that's normal /foo does not select namespaced nodes, it's the XPath spec.
It's probably #1 FAQ for XPath. As explained dozens of time you must bin a prefix to that namespace in the XPath context and use the prefix in
the query. I don't remember if/how it's doable from Python.


context = dom.xpathNewContext()
context.xpathRegisterNs(prefix, uri)

Now Daniel has time to look into my namespace-related bug report. :)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]