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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:02:30+00:00 2026-05-18T01:02:30+00:00

I’ve chosen the title here as my problem is I need to get the

  • 0

I’ve chosen the title here as my problem is I need to get the Item nodes mentioned in the example.
I have the following XML and am having problems using LINQ to query it, I’ve been able to parse XML before – however I’ve been stuck on this for hours and hope someone can help.
Here is my XML data below (example data):

<a:entry
    xmlns:a="http://www.w3.org/2005/Atom">
    <a:id>98765</a:id>
    <info>Data Catalogue</info>
    <data>
        <items>
            <item>
                <id>123456</id>
                <value>Item One</value>
            </item>
            <item>
                <id>654321</id>
                <value>Item Two</value>
            </item>
        </items>
    </data>
    <items>
        <item>
            <id>123456</id>
            <value>Item One</value>
        </item>
        <item>
            <id>654321</id>
            <value>Item Two</value>
        </item>
    </items>
    <a:author>
        <a:name>Catalogue</a:name>
    </a:author>
</a:entry>

I want to be able to extract the ID from the Item XML tag under Items, however there is an Items Tag with Item entries under data I DO NOT want these nodes at all – I want root/items/id/id if this were expressed as path. I’ve tried everything I know with LINQ so if someone could help, things to note although this is sample data it is based on the system – the format cannot be changed so that is not an acceptable solution.
I can’t seem to determine where I’m going wrong – every LINQ expression I try returns nothing, I think the namespace is an issue and have tried to integrate this but I’m going in circles.
Solution must work in Silverlight and C#

I have tried the following:

IEnumerable<XElement> nodes =
    element.Elements().Where(e => e.Name.LocalName == "items")

However this gets me all the "items" including the ones under "data" I don’t want those.


If I do the following on my XML I do see the Names of the Elements displayed:

XElement element = XElement.Parse(data);
foreach (XElement node in element.Elements())
{
  MessageBox.Show(node.Name.LocalName);
}

However when I do this I cannot see the node names under items at all – I’ve checked the XElement and it does have the node and when I output the names above it "items" shows up along with info and id!

foreach (XElement node in element.Elements("items"))
{
  MessageBox.Show(node.Name.LocalName);
}
  • 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-18T01:02:30+00:00Added an answer on May 18, 2026 at 1:02 am

    Assuming element is your <a:entry> element:

    var ids = element.Element("items")
                     .Elements("item")
                     .Select(item => item.Element("id").Value);
    

    The Element and Elements methods return only direct children, not all descendants, so it doesn’t return the <items> element which is under <data>

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

Sidebar

Related Questions

No related questions found

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.