Forum
»
Tutorials & FAQ
»
How-To's
»
How do I use XPath with XML namespace
  Rank: Paid supportJoined: 2/26/2008(UTC) Posts: 1,520  Location: Amsterdam Thanks: 114 times Was thanked: 220 time(s) in 188 post(s)
|
If you have an XML file which includes a namespace you have to use a prefix in your XPath expression. Here you have a sample XML file with a namespace: http://someurl.org/2012Code:<?xml version="1.0" encoding="utf-8"?>
<test attribute1="nothing here" xmlns="http://someurl.org/2012">
<book>
<name>title1</name>
</book>
<book>
<name>title2</name>
</book>
</test>
Normally you should use /test[1]/book[2]/name[1] to get the title2 as result. Now with the namespace in the XML file, add the namespace in the Namespaces list and add a prefix, e.g. x. You should change the XPath expession to: / x:test[1]/ x:book[2]/ x:name[1] Now you get the title2 as result. ErikC attached the following image(s): |
Uses Visualcron since 2006. |
 3 users thanked ErikC for this useful post.
|
|
|
Users browsing this topic |
Guest
|
Forum
»
Tutorials & FAQ
»
How-To's
»
How do I use XPath with XML namespace
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.