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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:52:18+00:00 2026-06-04T03:52:18+00:00

I have to read xml file. I did it but i had a problem.

  • 0

I have to read xml file. I did it but i had a problem.
I have xml like this

  <?xml version="1.0" encoding="windows-1254" ?> 
- <Xm>
- <Products>
  <Product_No>NT-7</Product_No> 
  <Stok>1</Stok> 
  <Product_Details>something</Product_Details> 
  <Desi>0,2</Desi> 
- <Variant>
  <VariantAd>size</VariantAd> 
  <Options>68 cm</Options> 
  </Variant>
  </Products>
- <Products>
  <Product_No>NT-15</Product_No> 
  <Stok>1</Stok> 
  <Product_Details>something</Product_Details> 
  <Desi>0,2</Desi> 
- <Variant>
  <VariantAd>size</VariantAd> 
  <Options>68 cm</Options> 
  <Options>74 cm</Options> 
  </Variant>
  </Products>
  </Xm>

I can read everyting, but my problem is i cant seperate options.

  <Options>68 cm</Options> 
  <Options>74 cm</Options> 

I cant read it together. I need to read it together and join them as string.

System.Xml.XmlNodeList lst = root.GetElementsByTagName("Product_No");
foreach (System.Xml.XmlNode n in lst)
{
    Product_No.Add(n.InnerText);
}
lst = root.GetElementsByTagName("Stok");
foreach (System.Xml.XmlNode n in lst)
{
    Stok.Add(n.InnerText);
}
lst = root.GetElementsByTagName("Product_Details");
foreach (System.Xml.XmlNode n in lst)
{
    Product_Details.Add(n.InnerText);
}
lst = root.GetElementsByTagName("Options");
foreach (System.Xml.XmlNode n in lst)
{
    Options.Add(n.InnerText);
}

How can i read and join them ?

  • 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-04T03:52:22+00:00Added an answer on June 4, 2026 at 3:52 am

    Linq2Xml can make the life easier

    var items = xDoc.Descendants("Products")
        .Select(p => new
        {
            ProductNo=p.Element("Product_No").Value,
            Stok = p.Element("Stok").Value,
            ProductDetails = p.Element("Product_Details").Value,
            Options = String.Join(";",p.Descendants("Options").Select(o=>o.Value))
        })
        .ToArray();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a really simple XML file that I'm trying to read, but I
I have this script, to read xml file. The file contains coordinates and I
I have to read/write an XML file that stores its data as bit masked
I have an xml file(from federal government's data.gov) which I'm trying to read with
I have an XML file as follows, and I'm trying to read the content
I have to read the xml node name from the following XML, but I
I have read that you can do it, but would this really improve performance
I have an XML file which I need to read and load the data
Respected All, I have to read XML file, for that I use SAXParser and
I have read this tutorial to write my hello world application with spring mvc.But

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.