Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2006

Tip: Looking for answers? Try searching our database.

SelectSingleNode Issue

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob Mixon [SPS MVP] - 04 Jul 2006 22:18 GMT
All,

There 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" );
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!

----------------------------------------------------------
Bob Mixon
Managing Director
ShareSquared, Inc. - Your Knowledge Management Experts!
http://www.ShareSquared.com

Microsoft SharePoint Portal Server MVP
(Blog) http://bobmixon.xwiki.com
----------------------------------------------------------
Jon Skeet [C# MVP] - 05 Jul 2006 01:23 GMT
<snip>

> I am having a difficult time setting up the NamespaceManager and making the
> SelectSingleNode call correctly to return the <contractRef> element.  Can
[quoted text clipped - 9 lines]
>
> 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);

Signature

Jon Skeet - <skeet@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

Bob Mixon [SPS MVP] - 05 Jul 2006 08:40 GMT
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
----------------------------------------------------------

> <snip>
>
[quoted text clipped - 19 lines]
> XmlNode node = discoveryElem.SelectSingleNode("//scl:contractRef",
> nm)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.