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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:51:16+00:00 2026-06-07T01:51:16+00:00

Three part question. Is it possible to locate a specific XML node by a

  • 0

Three part question.

Is it possible to locate a specific XML node by a child inside of it to retrieve other children of the parent? Example:

<House>
    <Kitchen>
        <Appliance>
            <Name>Refrigerator</Name>
            <Brand>Maytag</Brand>
            <Model>F2039-39</Model>
        </Appliance>
        <Appliance>
            <Name>Toaster</Name>
            <Brand>Black and Decker</Brand>
            <Model>B8d-k30</Model>
        </Appliance>
    </Kitchen>
</House>

So for this, I would like to locate the appropriate Appliance node by searching for “Refrigerator” or “Toaster”, and retrieve the brand from it.

The second part of this question is this: Is this a stupid way to do it? Would using an attribute in the Appliance tag make this a lot easier? If so, how would I locate it that way?

As for the third part, once I locate the Appliance, how would I go about changing say, the Model, of that particular appliance?

  • 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-06-07T01:51:18+00:00Added an answer on June 7, 2026 at 1:51 am

    Using XLinq, you can perform this query fairly naturally:

    // Given:
    //   var xdoc = XDocument.Load(...);
    //   string applianceName = "Toaster";
    
    // Find the appliance node who has a sub-element <Name> matching the appliance
    var app = xdoc.Root
                  .Descendants("Appliance")
                  .SingleOrDefault(e => (string)e.Element("Name") == applianceName);
    
    // If we've found one and it matches, make a change
    if (app != null)
    {
        if (((string)app.Element("Model")).StartsWith("B8d-k30"))
        {
            app.Element("Model").Value = "B8d-k30 Mark II";
        }
    }
    
    xdoc.Save(@"output.xml"); // save changes back to the document
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a three part question based on a dataframe (df is example rows)
Possible Duplicate: Secure hash and salt for PHP passwords THREE part question: Which technique
This is actually a three-part question, which I'll explain below, but the questions are:
This is really a three-part question, but I've answered the first question myself: I'm
I have three divs stacked on each other but offset so that a part
Before I dive into the disscusion part a quick question; Is there a method
I understand the value of the three-part service/host/client model offered by WCF. But is
I'm building a claims database with the above schema so far. Three three-part key
I have a set of three double values as part of an anonymous expression
I know this is technically a 3 part question, but it is all in

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.