Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XPath and namespace problem

Status
Not open for further replies.

xpblueScreenOfDeath

Programmer
Sep 1, 2004
87
I retrieve an XML document through a webservice in the following format:
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)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top