How do I guarante node order for an Xpath 'OR' query

Posted by Tom Carter on Stack Overflow See other posts from Stack Overflow or by Tom Carter
Published on 2010-12-21T09:49:21Z Indexed on 2010/12/21 9:54 UTC
Read the original article Hit count: 253

Filed under:
|

I have a snippet of XML that looks like

<body>
   Some text....
   <nodeA>....</nodeA>
   more text
   <someOtherNode>
      <nodeA>.......</nodeA>
   </someOtherNode>
   <nodeB>.......</nodeB>  
   etc.....
</body>

I'm selecting all nodeA and NodeB nodes inside <body> using an XPATH query similar to "//nodeA|//nodeB"

As I understand it, .NET supports XPATH 1.0 which does not guarantee node order.

How can I guarantee selected nodes are returned in document order in my OR query : that's to say :

  nodeA, nodeA, nodeB

© Stack Overflow or respective owner

Related posts about .NET

Related posts about xpath