|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
SelectSingleNode IssueThere are so many newsgroups these days, I am not sure if this is the correct one I should be posting to; if not, I apoligize! I have the following xml file, this was generated by the .NET disco.exe utility. <?xml version="1.0" encoding="utf-8"?> <discovery xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.xmlsoap.org/disco/"> <contractRef ref="http://sps2003:81/Services/AdGroupsList/AdGroupsList.asmx?wsdl" docRef="http://sps2003:81/Services/AdGroupsList/AdGroupsList.asmx" xmlns="http://schemas.xmlsoap.org/disco/scl/" /> <soap address="http://sps2003:81/Services/AdGroupsList/AdGroupsList.asmx" xmlns:q1="http://tempuri.org/" binding="q1:AdGroupsListSoap" xmlns="http://schemas.xmlsoap.org/disco/soap/" /> </discovery> I am having a difficult time setting up the NamespaceManager and making the SelectSingleNode call correctly to return the <contractRef> element. Can someone please provide me with an example? Here is what I have so far: XmlNamespaceManager nm = new XmlNamespaceManager( doc.NameTable ); nm.AddNamespace( "xsd", "http://www.w3.org/2001/XMLSchema" ); XmlElement discoveryElem = doc.DocumentElement;nm.AddNamespace( "xsi", "http://www.w3.org/2001/XMLSchema-instance" ); XmlNode node = discoveryElem.SelectSingleNode( "//contractRef", nm ); The node variable always returns null. Thank you in advance for all of the help! ---------------------------------------------------------- Bob Mixon Managing Director ShareSquared, Inc. - Your Knowledge Management Experts! http://www.ShareSquared.com Microsoft SharePoint Portal Server MVP (Blog) http://bobmixon.xwiki.com ---------------------------------------------------------- Bob Mixon [SPS MVP] <bob.mi***@gmail.com> wrote:
<snip> > I am having a difficult time setting up the NamespaceManager and making the You need the namespace for the contractRef element:> SelectSingleNode call correctly to return the <contractRef> element. Can > someone please provide me with an example? Here is what I have so far: > > XmlNamespaceManager nm = new XmlNamespaceManager( doc.NameTable ); > nm.AddNamespace( "xsd", "http://www.w3.org/2001/XMLSchema" ); > nm.AddNamespace( "xsi", "http://www.w3.org/2001/XMLSchema-instance" ); > XmlElement discoveryElem = doc.DocumentElement; > XmlNode node = discoveryElem.SelectSingleNode( "//contractRef", nm ); > > The node variable always returns null. > > Thank you in advance for all of the help! XmlNode node = discoveryElem.SelectSingleNode("//scl:contractRef", nm); -- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too Thank you Jon, I really appreciate it!
---------------------------------------------------------- Bob Mixon Managing Director ShareSquared, Inc. - Your Knowledge Management Experts! http://www.ShareSquared.com Microsoft SharePoint Portal Server MVP (Blog) http://bobmixon.xwiki.com ---------------------------------------------------------- Show quote > Bob Mixon [SPS MVP] <bob.mi***@gmail.com> wrote: > > <snip> > >> I am having a difficult time setting up the NamespaceManager and >> making the SelectSingleNode call correctly to return the >> <contractRef> element. Can someone please provide me with an >> example? Here is what I have so far: >> >> XmlNamespaceManager nm = new XmlNamespaceManager( doc.NameTable ); >> nm.AddNamespace( "xsd", "http://www.w3.org/2001/XMLSchema" ); >> nm.AddNamespace( "xsi", "http://www.w3.org/2001/XMLSchema-instance" >> ); >> XmlElement discoveryElem = doc.DocumentElement; >> XmlNode node = discoveryElem.SelectSingleNode( "//contractRef", nm ); >> The node variable always returns null. >> >> Thank you in advance for all of the help! >> > You need the namespace for the contractRef element: > > nm.AddNamespace( "scl", "http://schemas.xmlsoap.org/disco/scl/"); > ... > XmlNode node = discoveryElem.SelectSingleNode("//scl:contractRef", > nm); |
|||||||||||||||||||||||