Open GoogleCodeExporter opened 9 years ago
Thanks, for reporting, but I have problem reproducing your issue. When I create
a simple XML file, "//" works well there. I'm not sure, why it doesn't work
with your file yet, but I tried to check it in notepad++ and have problem
evaluating the XPath there. Are you using "XML Tools -> Evaluate XPath
expression" in notepad++? Please, let me know, so we can narrow down the issue.
Thx.
Original comment by stoupa91
on 21 Jan 2013 at 5:06
Ok, I got it. There is "problem" with the declared namespace. For the time
being you can use any of those two solutions:
1) Remove the namespace from you XML document
2) Let the XPath plugin know about the namespace(s).
(On the right side of the plugin view declare new namespace with (let's say) Prefix "x" and URI "http://www.w3.org/1999/xhtml" (both without the apostrophes). Then you can use following XPath query "//x:table" and it will find the correct results.)
I will think about more user friendly way to handle namespaces and will see
what can be done. Thanks for raising up this issue.
Original comment by stoupa91
on 21 Jan 2013 at 5:29
In Notepad++ I used the XPatherizerNPP plugin.
Sorry for uploading the huge file in the first place. I wanted to test what was
wrong with the file, but was out of time. You have been much too fast so that I
could search for the reason myself. ;)
Ok so since the namespace attribute assigns this namespace to all child
elements, it does not match because it only looks in the global namespace. I
checked how a few XML libraries handle issue, a few will find the node without
a namespace, others won't, matching the behavior of your code.
A possibility would be to e.g. have a 'default namespace' field. Quite like
Saxon XPath two provides a settings for a default namespace.
Or maybe for the really crazy ones a 'ignore namespace' (only use local names)
options might be viable.
As a sidenode for others reading: XPath has a way of finding the nodes
regardless of namespace, which is through the use of [local-name()=...]
Original comment by waa...@gmail.com
on 21 Jan 2013 at 4:48
Original issue reported on code.google.com by
waa...@gmail.com
on 20 Jan 2013 at 2:18Attachments: