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