473,498 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trouble with XmlNodeList

Roe
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
Nov 11 '05 #1
1 2407
Roe wrote:
//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.


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);
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
9618
by: Peter Nofelt | last post by:
Hey All, I'm running into this issue with parsing through an xml document by tag name. Below is an example xml document: File Name: things.xml <things> <people> <name>Peter</name>
1
1434
by: Roshawn Dawson | last post by:
Hi, I have the following line of code that continues to give me the "Object not set to an instance of an object" error: <%# CType(Container.DataItem,...
0
1495
by: Matthew.DelVecchio | last post by:
hello, i am attempting to do some databinding of an XmlNodeList to a DropDownList. id like to avoid looping thru my nodelist and hoped to do a simple .DataSource/.DataBind technique. for...
3
5794
by: Maurice Cosgrave | last post by:
Hi, I was wondering if there was a way to move values from an array into an XmlNodeList? I have the values loaded into a string array from a previous point in the application; now I need to...
4
4597
by: SkyHook | last post by:
1. Under the topic "Select Nodes Using XPath Navigation" it says: "All XmlNodeList objects are synchronized with the underlying document, therefore if you ... modify the value of a node, that node...
1
7985
by: bigeddie | last post by:
Hi, I'm trying to get an instance off a XmlNodeList without using selectNodes(...) XmlNodeList test1 = new XmlNodeList(); (C#) but that doesn't work. What's my mistake?
4
7764
by: eggie5 | last post by:
Hi, I have an XmlNodeList and I need to reverse it. Just like Array.Reverse(), but it has to stay as an XmlNodeList. Any ideas?
0
2198
by: nandha8210 | last post by:
hi all, i want to sort an XmlNodeList based on a innertext value of a XmlNode in the XmlNodeList and would like to save the sorted order to be reflected in the source XML document from where the...
2
2274
by: sarabonn | last post by:
hallo everyone, iam getting a xmlnodelist and how can i read the attributes of it ?.. This is my code line. XmlNodeList doc = xdoc.GetElementsByTagName("sioc:Item"); ...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7203
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4588
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3081
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
290
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.