How do I use XPath with XML namespace - VisualCron - Forum

Community forum

Welcome Guest! To enable all features please Login or Register.



Go to last post Go to first unread
Offline ErikC  
#1 Posted : Wednesday, August 15, 2012 12:14:10 PM(UTC)

Rank: Paid support

Joined: 2/26/2008(UTC)
Posts: 1,520
Location: Amsterdam

Thanks: 114 times
Was thanked: 221 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:

<?xml version="1.0" encoding="utf-8"?>
<test attribute1="nothing here" xmlns="">

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):
15-08-2012 12-12-37.jpg
Uses Visualcron since 2006.
thanks 3 users thanked ErikC for this useful post.
Support on 8/15/2012(UTC), osirisja on 8/15/2012(UTC), Lasse Lehtinen on 4/10/2014(UTC)
Users browsing this topic
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.

Scroll to Top