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 / XML / July 2003

Tip: Looking for answers? Try searching our database.

Trouble with XmlNodeList

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roe - 08 Jul 2003 01:01 GMT
Hi!

Here's my code:

//xd is an XmlDocument object, xnm is an XmlNameSpaceManager
XmlNodeList xnl = xd.SelectNodes
("/bd:SubscriptionInfoSet/bd:SubscriptionInfo",xnm);
                   
//TEST: Check to see if we selected any nodes...print what we selected
Response.Write(xnl.Item(0).InnerXml);
Response.Write("\r\n" + xnl.Count);

OK...so, here is my nightmare.

The xnl.count always returns 1...and I can't iterate through the
nodes. However, the InnerXml displays all of the nodes that should
have been selected.

I attempted to iterate with a foreach loop, with an iEnumerator and
with an XPathNodeIterator -- none of these work because xnl is
CONVINCED there is only one node. But the InnerXml displays LOTS of
nodes, in fact, all of the ones it should.

What is going on?

Thanks in advance,

Robert
Oleg Tkachenko - 08 Jul 2003 09:53 GMT
> //xd is an XmlDocument object, xnm is an XmlNameSpaceManager
> XmlNodeList xnl = xd.SelectNodes
[quoted text clipped - 9 lines]
> nodes. However, the InnerXml displays all of the nodes that should
> have been selected.

Sorry, but you are printing out InnerXml value of the first selected node.
InnerXml is *inner* XML - it includes all children nodes, but not the node
itself. If you need to select children of bd:SubscriptionInfo element, use
xd.SelectNodes("/bd:SubscriptionInfoSet/bd:SubscriptionInfo/node()",xnm);
Signature

Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel


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.