xpblueScreenOfDeath
Programmer
- Sep 1, 2004
- 87
I retrieve an XML document through a webservice in the following format:
The problem is I can't seem to use XPath to query the xml document. If I remove the default namespace or change the default namespace to "xmlns:aaa=...." then the XPath query works fine. What am I doing wrong?
Code:
<message xmlns="[URL unfurl="true"]http://www.someurl.com/messaging">[/URL]
<header>
...
</header>
<body>
<command>
...
</command>
</body>
</message>
The problem is I can't seem to use XPath to query the xml document. If I remove the default namespace or change the default namespace to "xmlns:aaa=...." then the XPath query works fine. What am I doing wrong?
Code:
doc.LoadXml("<message xmlns="[URL unfurl="true"]http://www.someurl.com/messaging"><header>...</header><body><command><Place>...</Place></command></body></message>")[/URL]
nsmgr = new System.Xml.XmlNamespaceManager(doc.NameTable)
nsmgr.AddNamespace(String.Empty, "[URL unfurl="true"]http://www.surescripts.com/messaging")[/URL]
node = doc.SelectSingleNode("/message/body/command", nsmgr)