[xml] xpathEval and namespaces



Hi,

My prototype program (Python libxml2 binding) calling some xpathEval
methods works fine if I use no namespaces (no xmlns properties in the
root node and no namespace prefixes), but I only get empty nodesets
as soon as I use namespaces.

My smallest non-working example:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <html xmlns="http://www.w3.org/2002/06/xhtml2";
          xmlns:xforms="http://www.w3.org/2002/xforms";>
    <head>
    </head>
    </html>

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.

I found some discussions about namespaces and xpathEval on the net,
so it seems to be a FAQ, but I didn't find any code examples that 
lead me to a solution/workaround.

(Of course my real needs are more complex than this example, but
I first want to find out how to get this simple example working.)

Thanks,

--
--    Jos Vos <jos xos nl>
--    X/OS Experts in Open Systems BV   |   Phone: +31 20 6938364
--    Amsterdam, The Netherlands        |     Fax: +31 20 6948204



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