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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:35:51+00:00 2026-06-03T13:35:51+00:00

I have a xml like this. <?xml version=1.0 encoding=utf-8 ?> <Category ID=1 AICategoryName=Schedule K:

  • 0

I have a xml like this.

<?xml version="1.0" encoding="utf-8" ?>
<Category ID="1" AICategoryName="Schedule K: Income/Loss" Taxonomy="K">
   <Level1 ID="11965" Name="Guaranteed payments" Taxonomy="4">
      <Level2 ID="27058" Name="Gtd Pmts(trade/bus) to Sch. M-1" Taxonomy="1"> 
      </Level2>

      <Level2 ID="27059" Name="Gtd Pmts not to Sch. M-1" Taxonomy="2">      
      </Level2>
   </Level1>

   <Level1 ID="119652" Name="2Guaranteed payments" Taxonomy="4">
      <Level2 ID="227058" Name="2Gtd Pmts(trade/bus) to Sch. M-1" Taxonomy="1"> 
      </Level2>

      <Level2 ID="227059" Name="2Gtd Pmts not to Sch. M-1" Taxonomy="2">      
      </Level2>
   </Level1>
</Category>

I want to get the child nodes under a parent node by providing the parent node attribite ID.

for example if I provide Level1 and 11965, I should get all the level 2 nodes and their Name and IDs.

I have tried this code.

XDocument xd = XDocument.Load(xmlPath);

        var xl = from xml2 in xd.Descendants("Level1")
                 where xml2.Parent.Attribute("ID").Value == parentNode.ID
                 select xml2;

But the code yeilds no results. also once I get the xl, how can I iterate through it to get child node names and IDs?

  • 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-03T13:35:53+00:00Added an answer on June 3, 2026 at 1:35 pm
    XDocument xd = XDocument.Load(xmlPath);
    var nodes = (from n in xd.Root.Desendants(tagName/*Level1*/) where n.Attribute("Id").Value == "idValue" select n.Elements()).single().select(n=>{return new{
    Id = n.attribute("Id").value,
    Name = n.attribute("Name").value,
    Taxonomy = n.attribute("Taxonomy").value
    }});
    

    you can also change the code above if the tag name requested is always “Level1” and the xml struvvture is fixed, to this.

    XDocument xd = XDocument.Load(xmlPath);
    var nodes = (from n in xd.Root.Elements("Level1") where n.Attribute("Id").Value == "idValue" select n.Elements()).single().select(n=>{return new{
        Id = n.attribute("Id").value,
        Name = n.attribute("Name").value,
        Taxonomy = n.attribute("Taxonomy").value
        }});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML structure like this: <?xml version=1.0 encoding=utf-8?> <categories version=2.0> <category> <name>cat1</name>
I have an XML file which looks like this : <?xml version=1.0 encoding=UTF-8?> <resultset
So say I have this XML file: <?xml version=1.0 encoding=utf-8 standalone=yes?> <Root> <Category Name=Tasties>
have an xml file like this. <?xml version =1.0 encoding =utf-8?> <menu> <menuNode title=Register
I have a xml like this: <?xml version=1.0 encoding=utf-8?> <assessment xmlns=http://xml.thinkcentral.com/pub/xml/hsp/assessment xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xhtml=http://www.w3.org/1999/xhtml xmlns:tia=http://xml.thinkcentral.com/pub/xml/hsp/tia
I have an xml file which looks like this <?xml version=1.0 encoding=UTF-8 ?> <BulkDataExchangeRequests
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 with this structure: <?xml version=1.0 encoding=utf-8 ?> <Photobank> <Landowner
I've got XML feed from public google calendar. Looks like this: <?xml version='1.0' encoding='UTF-8'?>
I have this xml: <?xml version=1.0 encoding=utf-8?> <xml> <head> <name>This is my XML</name> <version>This

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.