[lxml-dev] Bug in XPath evaluation
Torsten Rehn
scel at users.sourceforge.net
Sun Apr 22 22:05:42 CEST 2007
Hi list,
here's what I have:
poc.xml:
<?xml version="1.0" encoding="utf-8" ?>
<myrootnode>
<myns:mynode xmlns:myns="http.//www.example.com/myns">
<myns:mysubnode>some text</myns:mysubnode>
</myns:mynode>
</myrootnode>
poc.py:
#!/usr/bin/env python
from lxml import etree
DocTree = etree.parse("poc.xml")
QueryResult = DocTree.xpath("//myns:mynode")
The result (with added version info):
[gentop][scel@/home/scel/workspace/lxmlbug] > ./poc.py
lxml.etree: (1, 2, 1, 0)
libxml used: (2, 6, 27)
libxml compiled: (2, 6, 27)
libxslt used: (1, 1, 17)
libxslt compiled: (1, 1, 17)
Traceback (most recent call last):
File "./poc.py", line 9, in ?
QueryResult = DocTree.xpath("//myns:mynode")
File "etree.pyx", line 1256, in etree._ElementTree.xpath
File "xpath.pxi", line 75, in etree._XPathEvaluatorBase.evaluate
File "xpath.pxi", line 212, in etree.XPathDocumentEvaluator.__call__
File "xpath.pxi", line 105, in etree._XPathEvaluatorBase._handle_result
File "xpath.pxi", line 93, in etree._XPathEvaluatorBase._raise_parse_error
etree.XPathSyntaxError: error in xpath expression
The expression however, is valid (or I'm just insanely stupid).
I tested the same query on the same data using
http://dmag.upf.edu/contorsion/query.jsp and it worked just as it should.
Strangely, //*[name()='myns:mynode'] works with lxml.
Regards,
Torsten
--
Torsten Rehn <scel at users.sourceforge.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: This is a digitally signed message part
Url : http://codespeak.net/pipermail/lxml-dev/attachments/20070422/5ed9597b/attachment.pgp
More information about the lxml-dev
mailing list