Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6932567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:43:20+00:00 2026-05-27T11:43:20+00:00

Is there any way in XPath DOM Programming with using System.Xml to run selectNodes

  • 0

Is there any way in XPath DOM Programming with using System.Xml to run selectNodes (XPATH) with a sort parameter?

For example, with the following XML and program writes values in the same order as the document (descending). Is there a way using XPath to get the values in ascending order?

NOTE. Of course, you could pre-sort in XSL, however I need to update the values as I’m looping through them. Since XSL gives me a sorted copy of the elements, not the actual elements themselves, I can’t use XSL.

Here’s some XML, a program out output

public static void Main() {

        XmlDocument xml = new XmlDocument();
        xml.Load( "t.xml" );

        // SelectNodes gets in document order, but I want in 
            // ascending order based on @value
        foreach( XmlNode ndNode in xml.SelectNodes( "/xml/ele" ) ) {
            Console.WriteLine( ndNode.Attributes["value"].Value );
        }
    }

Here’s the XML

<xml>
<ele value='3' test='Third'/>
<ele value='2' test='Second'/>
<ele value='1' test='First'/>
</xml>

Finally the output in document (descending) order. I’d like an XPath that returns the nodes in ascending order.

3
2
1

PS, I’m using System.Xml in Visual Studio 2008 .NET 3.5

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:43:21+00:00Added an answer on May 27, 2026 at 11:43 am

    XPath doesn’t supprort ordering, however you may look at AddSort method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to check whether a file is locked without using a
Is there any way to listen to an Oracle AQ using a Perl process
Is there any way to search in XML doc with match case? In this
Is there any way, how I can to identify two xpath values in one.
Is there any way to capture the MouseDown even from the .NET 2.0 TextBox
Is there any way to apply an attribute to a model file in ASP.NET
Is there any way, in any language, to hook my program when a user
Is there any way to have something that looks just like a file on
Is there any way to include the SVN repository revision number in the version
Is there any way to use inheritance in database (Specifically in SQL Server 2005)?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.