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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:36:17+00:00 2026-05-24T03:36:17+00:00

Possible Duplicate: Parse XML Elements with LINQ I have an XML document that looks

  • 0

Possible Duplicate:
Parse XML Elements with LINQ

I have an XML document that looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<TestDataset xmlns="http://tempuri.org/TestDataset.xsd">
  <TaxRate>
    <Code>GST</Code>
    <Rate>0.05</Rate>
    <LastModified>2010-03-31T17:03:24.063-04:00</LastModified>
    <Deleted>0</Deleted>
    <AbbreviationEN>GST</AbbreviationEN>
    <AbbreviationFR>GST</AbbreviationFR>
    <GLSubCode>GST</GLSubCode>
  </TaxRate>
  <TaxRate>
    <Code>PST</Code>
    <Rate>0.08</Rate>
    <LastModified>2010-03-31T17:03:24.063-04:00</LastModified>
    <Deleted>0</Deleted>
    <AbbreviationEN>PST</AbbreviationEN>
    <AbbreviationFR>PST</AbbreviationFR>
    <GLSubCode>PST</GLSubCode>
  </TaxRate>
</TestDataset>

And I am trying to select it’s contents with the following query:

XDocument data = LoadTestData("TaxRate.xml");
var taxdata = (from x in data.Elements("TaxRate")
              select new
              {
                  Code = x.Element("Code").Value,
                  Rate = x.Element("Rate").Value,
                  AbbreviationEN = x.Element("AbbreviationEN").Value,
                  AbbreviationFR = x.Element("AbbreviationFR").Value,
                  GLSubCode = x.Element("GLSubCode").Value
               }).ToList();

However I keep getting no results, LoadTestData is loading the XML document fine.

  • 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-24T03:36:18+00:00Added an answer on May 24, 2026 at 3:36 am

    You forgot to include the namespace:

    XNamespace ns = "http://tempuri.org/TestDataset.xsd";
    XDocument data = LoadTestData("TaxRate.xml");
    var taxdata = (from x in data.Descendants(ns + "TaxRate")
                  select new
                  {
                      Code = x.Element(ns + "Code").Value,
                      Rate = x.Element(ns + "Rate").Value,
                      AbbreviationEN = x.Element(ns + "AbbreviationEN").Value,
                      AbbreviationFR = x.Element(ns + "AbbreviationFR").Value,
                      GLSubCode = x.Element(ns + "GLSubCode").Value
                   }).ToList();
    

    Although the namespace in your XML file is the default namespace, you still need to include it in your query.

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

Sidebar

Related Questions

Possible Duplicate: Parsing XML in Cocoa iPhone - Can we parse .plist(xml) file using
Possible Duplicate: How to parse and process HTML/XML with PHP? I want to grab
Possible Duplicate: Parse multiple doubles from string in C# Say I have a line
Possible Duplicate: Best XML Parser for PHP I have a string with XML data
Possible Duplicate: how to parse hex or decimal int in Python i have a
Possible Duplicate: Best method to parse various custom XML documents in Java HI all,
Possible Duplicate: How to parse a string to an int in C++? I have
Possible Duplicate: Whats the main difference between int.Parse() and Convert.ToInt32 I would like to
Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have

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.