I am using http://xpath.online-toolz.com/tools/xpath-editor.php
as an online XPath evaluator. I tried a few others but it’s all the same
I have the following in my xml :-
<?xml version="1.0"?>
<test xmlns="abc">
</test>
Now the XPath queries
/
.
gives me the output :-
<test xmlns="abc">
</test>
However, the queries
test
/test
//test
Do not give me any output at all. I’m doing a very basic mistake but I can’t figure out what. I think it’s got something to do with namespaces but changing the queries to
abc:test
doesn’t help either because it gives an Invalid Expression error.
I’m using http://www.w3schools.com/xpath http://www.tizag.com/xmlTutorial/xpathtutorial.php &
http://oreilly.com/perl/excerpts/system-admin-with-perl/ten-minute-xpath-utorial.html
as my sources for XPath tutorials.
You have no explicit namespace prefixes in your target file, but you still need to cater for them. You can write
Your “abc” is a namespaceURI, not a namespace prefix. It is probably invalid as most tools will test it for a URI form such as
A better file would be:
when your query would be:
I have tested this on your site and it works.
The form
will depend on a mechanism to set the prefix
abcto'http://www.abc.com/'and there doesn’t seem to be a mechanism on the site