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

  • Home
  • SEARCH
  • 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 6675641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:52:57+00:00 2026-05-26T03:52:57+00:00

Right now I have my code similar to this (actually one level deeper). If

  • 0

Right now I have my code similar to this (actually one level deeper). If the company name is equal to the node of company then create a node list from it (as I need to populate a drop down box with all of the details) —Not using 3.5 for this project 🙁

XmlNodeList elemList = xmlDoc.GetElementsByTagName("company");
foreach (XmlNode node in elemList)
{
    if (node.Attributes[0].Value == company)
    {   
        foreach (XmlNode child in node.ChildNodes)
        {
            foreach (XmlNode detail in child.ChildNodes)
            {
                ddlCodes.Items.Add(detail.Value.ToString());
            }
        }
    }
}

Not really liking all those foreach statements, just wondering if there is a cleaner way. Here is how my xml looks like

<companies>
    <company id="company1">
       <code>12</code>
       <detail>detail of 12 code</detail>
    </company>
    <company id="company2">
       <code>15</code>
       <detail>detail of 15 code</detail>
    </company>
</companies>
  • 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-26T03:52:57+00:00Added an answer on May 26, 2026 at 3:52 am

    Have a look at XPath and the XPathNavigator class, it provides you with a query language for XML

    Or you could use Linq to XML if you want but that depends on the .net framework you’re using.

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

Sidebar

Related Questions

Right now, I have code that looks something like this: Private Sub ShowReport(ByVal reportName
I have this code right now to get the row value from jquery grid..
Right now, I have this code where $obj_arr maybe contain array and an object.
Right now i have a line of code, in vb, that calls a text
I have some code right now that executes when a link is clicked. The
I have an odd edge case right now in that a response code from
I currently have code similar to this for a form: $('#some-form') .submit(function() { //
In a PHP project I am working on right now, I have some code
well right now I have this checkbox that's enabling / disabling a submit button
Not sure if I have the title right on this one, feel free to

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.