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 761689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:52:06+00:00 2026-05-14T15:52:06+00:00

Scenario: I am parsing values from an XML file using C# and have the

  • 0

Scenario:

I am parsing values from an XML file using C# and have the following method:

    private static string GetXMLNodeValue(XmlNode basenode, string strNodePath)
    {
        if (basenode.SelectSingleNode(strNodePath) != null)
            return (basenode.SelectSingleNode(strNodePath).InnerText);
        else
            return String.Empty;
    }

To get a particular value from the XML file, I generally pass the root node and a path like “parentnode/item”

I recently ran into an issue where two nodes at the same document level share the same name.

Why:

The duplicate nodes all need to be read and utilized; they have child nodes with differing values (which can distinguish them). At present I just have two nodes, each named <Process> and sub-nodes named <Name> which contain unique names. Other sub-nodes contain various values such as memory usage. When processing and storing the values for the sub-nodes, I would essentially ignore the parent node name and use my own names based on the sub-node <Name> value.

Question:

What is the best way to get the values for duplicate-named nodes distinctly? My thought was to load all values matching the node name into an array and then using the array index to refer to them. I’m not sure how to implement that, though. (I’m not well-versed in XML navigation.)

Sample XML

<?xml version="1.0" ?>
<info>
  <processes>
    <process>
        <name>program1</name>
        <memory_use>24.8</memory_use>
    </process>
    <process>
        <name>program2</name>
        <memory_use>19.0</memory_use>
    </process>
  </processes>
</info>
  • 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-14T15:52:06+00:00Added an answer on May 14, 2026 at 3:52 pm

    Use SelectNodes method instead it gives you a list of all nodes matching your Xpath

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

Sidebar

Related Questions

Having a hard time parsing XML created from a web-form using POST. Here's the
I am getting an XML format data from server and parsing it in an
What is the best way to handle the following database search scenario using asp.net
Parsing some data and inserting it into 3 tables from .NET. Using Table Valued
Scenario I'm parsing emails and inserting them a database using an ORM (NHibernate to
I am parsing an XSL file with XSL. And I have a problem dynamically
Scenario : I'll try to put an analogy with the loan broker example from
Scenario first :- I'm using Entity Framework to do some queries, to build my
Scenario While using the Maven Ant Task artifact:deploy , I'm encountering the error java.lang.OutOfMemoryError:
Scenario: Every page on the website will have a menu bar at the top

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.