Filetr XML using Xpath with key Value.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi I want to get the value for the key REG_LINK from the XML feed below, I tried the xpath but it does not work "onl:cceobject/onl:content/onl:extrafields/onl:extrafield/[onl:key=REG_LINK]"
<pre class="prettyprint <?xml version="1.0" encoding="UTF-8"?>
<onl:cceobject xmlns:onl="http://www.saxotech.com/online
<onl:content>
<onl:title><![CDATA[2013 Energy Symposium]]></onl:title>
<onl:extrafields>
<onl:extrafield type="text
<onl:key><![CDATA[CITY]]></onl:key>
<onl:displaytext><![CDATA[]]></onl:displaytext>
<onl:value><![CDATA[Camp Hill]]></onl:value>
</onl:extrafield>
<onl:extrafield type="text
<onl:key><![CDATA[CONTACT_NAME]]></onl:key>
<onl:displaytext><![CDATA[]]></onl:displaytext>
<onl:value><![CDATA[Colleen Jones]]></onl:value>
</onl:extrafield>
<onl:extrafield type="text
<onl:key><![CDATA[REG_LINK]]></onl:key>
<onl:displaytext><![CDATA[]]></onl:displaytext>
<onl:value><![CDATA[https://www.centralpennbusiness.com/section/Energy-Symp-Registration]]></onl:value>
</onl:extrafield>
<onl:extrafield type="text
<onl:key><![CDATA[STATE]]></onl:key>
<onl:displaytext><![CDATA[]]></onl:displaytext>
<onl:value><![CDATA[PA]]></onl:value>
</onl:extrafield>
<onl:extrafield type="text
<onl:key><![CDATA[STREET_ADDRESS]]></onl:key>
<onl:displaytext><![CDATA[]]></onl:displaytext>
<onl:value><![CDATA[1150 Camp Hill Bypass]]></onl:value>
</onl:extrafield>
<onl:extrafield type="text
<onl:key><![CDATA[VENUE]]></onl:key>
<onl:displaytext><![CDATA[]]></onl:displaytext>
<onl:value><![CDATA[Radisson Hotel Harrisburg]]></onl:value>
</onl:extrafield>
</onl:extrafields>
</onl:content>
</onl:cceobject>[/code]
I am using below code to get the value but it did not work please help:
<pre class="prettyprint xmlDoc.LoadXml(Return_XmLFeedByURL("XMLFeed URL");
XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xmlDoc.NameTable);
namespaceManager.AddNamespace("onl", "http://www.saxotech.com/online");

string strEventLink = xmlDoc.SelectSingleNode("onl:cceobject/onl:content/onl:extrafields/onl:extrafield/[onl:key=REG_LINK]", namespaceManager);[/code]
<br/>


View the full article
 
Back
Top