
Signature
Vikram Vamshi
Database Engineer
Eclipsys Corporation
> 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?
I think XPath rules will apply so on e.g. the child axis the nodes will
be in document order, on e.g. the preceding-sibling axis the nodes will
be in reversed document order.
See the XPath specification <http://www.w3.org/TR/xpath#axes>, an
excerpt says:
"An axis is either a forward axis or a reverse axis. An axis that
only ever contains the context node or nodes that are after the context
node in document order is a forward axis. An axis that only ever
contains the context node or nodes that are before the context node in
document order is a reverse axis. Thus, the ancestor, ancestor-or-self,
preceding, and preceding-sibling axes are reverse axes; all other axes
are forward axes. Since the self axis always contains at most one node,
it makes no difference whether it is a forward or reverse axis."

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Vikram Vamshi - 12 Jun 2006 23:58 GMT
Martin,
I did read the document, from what I understand it says that the nodes in
the node-set are based upon the axis that you select.
Howerver it does not impose any ordering on the nodes within the final
node-set.
So the 'axis' simply acts like a filtering mechanism. Did I misinterpret it?
Thanks for taking your time to respond.
Vikram

Signature
Vikram Vamshi
Database Engineer
Eclipsys Corporation
>
>> If I execute XmlNode.SelectNodes("some xpath query") and then use foreach
[quoted text clipped - 16 lines]
> Since the self axis always contains at most one node, it makes no
> difference whether it is a forward or reverse axis."
> If I execute XmlNode.SelectNodes("some xpath query") and then use foreach to
> iterate over it.
[quoted text clipped - 6 lines]
> This is very crucial to our design, otherwise I will have to add a
> "sequence" attribute and then order by the sequence.
http://msdn2.microsoft.com/en-us/microsoft.office.interop.word.xmlnode.selectnod
es.aspx
"Returns a XMLNodes collection that represents all the nodes that match
a specified XPath string in the order in which they appear."

Signature
Oleg Tkachenko [XML MVP, MCAD]
http://www.XmlLab.Net | http://www.XLinq.Net | http://blog.tkachenko.com
Vikram Vamshi - 13 Jun 2006 16:22 GMT
That is from the word interop documentation, do you think the same will hold
true for the .net 2.0 framework.

Signature
Vikram Vamshi
Database Engineer
Eclipsys Corporation
>> If I execute XmlNode.SelectNodes("some xpath query") and then use foreach
>> to iterate over it.
[quoted text clipped - 11 lines]
> "Returns a XMLNodes collection that represents all the nodes that match a
> specified XPath string in the order in which they appear."
Oleg Tkachenko [MVP] - 14 Jun 2006 09:21 GMT
> That is from the word interop documentation, do you think the same will hold
> true for the .net 2.0 framework.
Yes. But if your whole design depends on this feature you better sort
selected nodes explicitly. XmlNode.SelectNodes is just a wrapper for
XPathNavigator.Select, so instead SelectNodes use XPathNavigator,
compiled XPathExpression and AddSort() method to sort nodes by preceding
nodes count.

Signature
Oleg Tkachenko [XML MVP, MCAD]
http://www.XmlLab.Net | http://www.XLinq.Net | http://blog.tkachenko.com
Vikram Vamshi - 15 Jun 2006 15:53 GMT
Thanks!!!

Signature
Vikram Vamshi
Database Engineer
Eclipsys Corporation
>> That is from the word interop documentation, do you think the same will
>> hold true for the .net 2.0 framework.
[quoted text clipped - 4 lines]
> XPathExpression and AddSort() method to sort nodes by preceding nodes
> count.
Hi, Nice Replies those are worth ful..
Please have a look at my blog
http://dotnethangout.blogspot.com/2007/02/xml-in-net.html
Please Visit
http://dotnethangout.blogspot.com/2007/02/xml-in-net.html