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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:59:05+00:00 2026-06-15T03:59:05+00:00

My XML looks like this: <product id=1> <name>A thing</name> <description>This is what it’s like</description>

  • 0

My XML looks like this:

<product id="1">
    <name>A thing</name>
    <description>This is what it's like</description>
</product>

I’ve been looking for an example that might look something like this:

string productID = 1;
XDocument productsXML = XDocument.Load("Products.xml");
for item in productsXML {
    if (item.ID == productID) {
        productNameLabel.Text = item.name;
    }
}

The idea being, I’ll be able to output a single xml child element to the .aspx page.

A thing

Does that make sense? I’ve been looking for examples for a few hours, and I’m starting to think that there is lot more scaffolding that I need, but since all the examples are so different, I’m not sure which one to follow!

So, how can I grab the contents of a single XML child element, and output it to the .aspx? Take this:

<product id="1">
    <name>A thing</name>
    <description>This is what it's like</description
</product>

and output this:

A thing
  • 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-15T03:59:06+00:00Added an answer on June 15, 2026 at 3:59 am

    You can use XPath (in System.Xml.XPath)

    string value = productsXML.XPathSelectElement("//product[@id='1']/name").Value;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For an XML document that looks like this, <Products> <productTypes> <productType name=BigOranges> <product> <name>BigOrange1</name>
I am searching an xml file that looks like this: <producers> <producer> <name></name> <owner></owner>
my xml structure looks like this: <entity id=1000070> <name>apple</name> <type>category</type> <entities> <entity id=7002870> <name>mac</name>
I've got XML that looks like this: <item> <itemDate>07/10/2009</itemDate> </item> I would like to
This is how my XML looks like : <Product sequence_number=1 number=1543448904 id=S1 unit_number=1> <consumer_narrative
This is how my XML looks like : <Product sequence_number=1 number=1543448904 id=S1 unit_number=1> <consumer_narrative
I have an XML feed that looks like this: <?xml version=1.0 encoding=UTF-8?> <productFeed version=1.0
I have an xml file that looks like this: <args> <sometag value=abc /> <anothertag
So I have some XML that generally looks like this <wd:Data xmlns:wd=urn:com.foo.bar/GetResult> <wd:Result> <wd:field1>lorem</wd:field1>
My xml looks like this: <nodes><skus><sku>abc</sku><sku>def123</sku></skus></nodes> I want to get all the elements with

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.