EDN Admin
Well-known member
I am parsing xml with namespaces, my xpath statements do have Namespace prefixes. I got the idea of adding namespace managers from
http://carso-owen.blogspot.com/2009/02/how-to-get-data-from-msn-navigation.html
Carso Leons Blog . Still I am getting the same error.
Here is the complete information
XML
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; Agent<span style="color:Blue; :<span style="color:#A31515; Work <span style="color:Red; xmlns:Agent<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://www.MyCompany.com/Product/Agent<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Agent<span style="color:Blue; :<span style="color:#A31515; WorkType<span style="color:Blue; >GroupReload<span style="color:Blue; </<span style="color:#A31515; Agent<span style="color:Blue; :<span style="color:#A31515; WorkType<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Agent<span style="color:Blue; :<span style="color:#A31515; WorkDate<span style="color:Blue; ><span style="color:Blue; </<span style="color:#A31515; Agent<span style="color:Blue; :<span style="color:#A31515; WorkDate<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Agent<span style="color:Blue; :<span style="color:#A31515; Work<span style="color:Blue; >
[/code]
<br/>
C# Code to parse
<div style="color:Black;background-color:White; <pre>
XmlDocument doc = <span style="color:Blue; new XmlDocument();
doc.LoadXml(xml);
XmlNamespaceManager namespaceManager = <span style="color:Blue; new XmlNamespaceManager(doc.NameTable);
namespaceManager.AddNamespace(<span style="color:#A31515; "Agent", <span style="color:#A31515; "http://www.MyCompany.com/Product/Agent");
XmlNode node = doc.SelectSingleNode(<span style="color:#A31515; "/Agent:Work/Agent:WorkType"); <span style="color:Green; // Still getting error on this line.
[/code]
What am I missing here ? Please help.
Thanks, <hr class="sig Fahad
View the full article
http://carso-owen.blogspot.com/2009/02/how-to-get-data-from-msn-navigation.html
Carso Leons Blog . Still I am getting the same error.
Here is the complete information
XML
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; Agent<span style="color:Blue; :<span style="color:#A31515; Work <span style="color:Red; xmlns:Agent<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://www.MyCompany.com/Product/Agent<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Agent<span style="color:Blue; :<span style="color:#A31515; WorkType<span style="color:Blue; >GroupReload<span style="color:Blue; </<span style="color:#A31515; Agent<span style="color:Blue; :<span style="color:#A31515; WorkType<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Agent<span style="color:Blue; :<span style="color:#A31515; WorkDate<span style="color:Blue; ><span style="color:Blue; </<span style="color:#A31515; Agent<span style="color:Blue; :<span style="color:#A31515; WorkDate<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Agent<span style="color:Blue; :<span style="color:#A31515; Work<span style="color:Blue; >
[/code]
<br/>
C# Code to parse
<div style="color:Black;background-color:White; <pre>
XmlDocument doc = <span style="color:Blue; new XmlDocument();
doc.LoadXml(xml);
XmlNamespaceManager namespaceManager = <span style="color:Blue; new XmlNamespaceManager(doc.NameTable);
namespaceManager.AddNamespace(<span style="color:#A31515; "Agent", <span style="color:#A31515; "http://www.MyCompany.com/Product/Agent");
XmlNode node = doc.SelectSingleNode(<span style="color:#A31515; "/Agent:Work/Agent:WorkType"); <span style="color:Green; // Still getting error on this line.
[/code]
What am I missing here ? Please help.
Thanks, <hr class="sig Fahad
View the full article