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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:53:24+00:00 2026-05-27T17:53:24+00:00

I have a very basic XML file that looks like this: <allData> <allDataDetails> <quoteid>ABC123</quoteid>

  • 0

I have a very basic XML file that looks like this:

<allData>
  <allDataDetails>
    <quoteid>ABC123</quoteid>
    <customername>John Smith</customername>
  </allDataDetails>
  <allDataDetails>
    <quoteid>DEF456</quoteid>
    <customername>Jane Doe</customername>
  </allDataDetails>
</allData>

My XSD specifies that at least 1 allDataDetails element must exist. The doc is validated fine.

When querying using Linq to XML, though, I cannot seem to recognize or query for the inner elements within allData. Instead, when I view in the debugger, the Value attribute is all the data concatenated. It looks like this:

ABC123John SmithDEF456Jane Doe

Here’s my query code. myRows is always null, because I cannot seem to get the descendants:

XDocument entityXml = XDocument.Parse(myDataString);

var myRows = from d in entityXml.Descendants("allDataDetails")
             select new
             {
                quoteid = d.Element("quoteid").Value,
                customername = d.Element("customername").Value
             };

Anyone know what could be wrong here?

  • 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-27T17:53:25+00:00Added an answer on May 27, 2026 at 5:53 pm

    I just run your sample code, and few syntax error were fixed:
    and also a comma for the value customer name was wrong, try my version below, it should work.

    string myDataString = @"<allData>
                              <allDataDetails>
                                <quoteid>ABC123</quoteid>
                                <customername>John Smith</customername>
    
                              </allDataDetails>
                              <allDataDetails>
                                <quoteid>DEF456</quoteid>
                                <customername>Jane Doe</customername>
    
                              </allDataDetails>
                            </allData>";
                 XDocument entityXml = XDocument.Parse(myDataString);
    
    
                 var myRows = from d in entityXml.Descendants("allDataDetails")
                          select new
                            {
                                quoteid = d.Element("quoteid").Value
                                ,customername = d.Element("customername").Value
                            };
                 foreach (var rw in myRows)
                     Console.WriteLine(rw.customername + "\t" + rw.quoteid);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app.config file that looks like this: <?xml version=1.0 encoding=utf-8 ?> <configuration>
I have a very short (so far), very basic XML file called config.xml like
I have a very large XML file that I need to parse so I
I have a very basic question on usage of resource files (like XML etc.)
I have a basic XML file that I load in my PHP using $xml
Greetings, I'm new to TCL scripting, and I have a very very basic xml
I have a very basic mysql table called memberships, that tracks which people belong
I have some very basic semaphore code that works great on Linux, but cannot
I have a very basic doubt regarding the method that gets executed when app
I have a very basic data class that is subclassed from NSObject. I declare

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.