473,668 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SelectNodes correct order?

If I use XmlNode.SelectN odes() in my program and then use
foreach XmlNode node in XmlNodeList am I guaranteed to get the nodes in
the order in which they appear in the original xml document source?

Thanks in advance.

Adam Smith

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
3 2349
Yep.

-----------
"Adam Smith" <ad*********@ho tmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
If I use XmlNode.SelectN odes() in my program and then use
foreach XmlNode node in XmlNodeList am I guaranteed to get the nodes in
the order in which they appear in the original xml document source?

Thanks in advance.

Adam Smith

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #2

Is there any difference between using foreach and the count property, as
in:

XmlNodeList elemList = root.SelectNode s("//title");

for (int i=0; i < elemList.Count; i++)
{
//Display all book titles in the Node List.
Console.WriteLi ne(elemList[i].InnerXml);
}

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3
It should still list the nodes in the order in which it is defined in the
document. I have'nt noticed any difference between these 2 approaches.

In fact I would be surprised if the node order is different, since this
necessary to the validity of some XML documents.

-----------------
"Adam Smith" <ad*********@ho tmail.com> wrote in message
news:Ow******** ******@tk2msftn gp13.phx.gbl...

Is there any difference between using foreach and the count property, as
in:

XmlNodeList elemList = root.SelectNode s("//title");

for (int i=0; i < elemList.Count; i++)
{
//Display all book titles in the Node List.
Console.WriteLi ne(elemList[i].InnerXml);
}

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #4

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

Similar topics

8
6439
by: e-mid | last post by:
i want to get childs of specific xml node. normally i use xmlNodeList fooList = myNode.SelectNodes("foo"); but in compactframework , there is no selectNodes() method or selectSingleNode() method. what else can i use instead?
1
1733
by: Riko Eksteen | last post by:
Hi I am writing an application that listens to the NodeInserted event, and if the event is fired it does a selectnodes xpath query on the XmlDocument. Only problem is, when I call SelectNodes(string, XmlNameSpaceManager) the NodeInserted event gets fired as well, without me doing any modifucation of the document. This results in an infinite loop of metod calls and callbacks in my app, and eventually a stack overflow in the XmlDocument.
2
1756
by: Michael H | last post by:
Hello group, I have a some xml that looks like this below: <tuneRequests ct="3" xmlns:sql="urn:schemas-microsoft-com:xml-sql" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <tr xsi:type="trGenericType" number="2">
2
2183
by: Linda Boumarafi | last post by:
Hi, This is a newbie question to XMLNS. I just finished the article on "XML Namespaces and How They Affect XPath and XSLT" by Dare Obasanjo and I'm pretty sure I understand the problem. I just don't know how to achieve the desired XPath result. I'm dealing with an XML document that has two XMLNS' in the root node (Report) and I'm ending up with 0 results using SelectNodes. If I take out both namespaces, the SelectNodes(XPathQuery) works...
2
4394
by: Joe | last post by:
Hello All: Does anyone know the differnce between the GetElementsByTagName method and the SelectNodes method? I know that they take different arguments. They also both return a NodeList. I'm wondering when would I use one vs. the other. TIA, -- Joe
8
12076
by: Vikram Vamshi | last post by:
If I execute XmlNode.SelectNodes("some xpath query") and then use foreach to iterate over it. Will it guaratee that the order of nodes I get will be same as the order of nodes in the original xml document? Can someone point me to a document which states that the order is (or is not) guarateened (I could not find any when i did my search on msdn). This is very crucial to our design, otherwise I will have to add a "sequence" attribute...
2
3216
by: DeveloperX | last post by:
SelectNodes under 1.1 is confusing me. Imagine an xml file that looks like this. It's just an example: <drive> <dir a="a"> <file>aA</file> <file>aB</file> <dir a="ab"> <file>abA</file> <dir a=abc>
3
2406
by: John Smith | last post by:
I'm trying to make some Javascript X-browser. foo is a HTML DOM. I have foo.documentElement.selectNodes("xpath"); in the source. I see later down there is also a foo.transformNode. Yuck. Has someone written a x-browser selectNodes/transformNode implementation so that I can get this code working in a non IE browser??
3
10696
by: Ben | last post by:
Hi We have the XML Below <Products> <Item Code="1"> <PN>Name</PN> <PC>ProductCode</PC> <MC>Manufacturer</MC> ......
0
8462
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8586
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8658
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7405
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5682
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1787
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.