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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:10:55+00:00 2026-05-23T07:10:55+00:00

i have a xml like following one. <testing> <node01 name=node01Name> <node02s> <node02 name=1> <CustomProperties>

  • 0

i have a xml like following one.

  <testing>
  <node01 name="node01Name">
    <node02s>
      <node02 name="1">
        <CustomProperties>
          <CustomProperty Name="ASCII File Name" Value="index.txt" FilterID="0" />
          <CustomProperty Name="ASCII Folder" Value="\\abc\cdf\aaaa" FilterID="0" />
          <CustomProperty Name="Delimiter" Value="CommaQuote" FilterID="0" />
          <CustomProperty Name="Duplicate Handling" Value="Replace if Dup" FilterID="0" />
          <CustomProperty Name="EMAILATTDOC" Value="1" FilterID="0" />
          <CustomProperty Name="EMAILATTINDEX" Value="0" FilterID="0" />
          <CustomProperty Name="EMAILOUTBODY" FilterID="0" />
          <CustomProperty Name="EMAILOUTCC" FilterID="0" />
        </CustomProperties>
      </node02>
      <node02 name="2">
        <CustomProperties>
          <CustomProperty Name="ASCII File Name" Value="index.txt" FilterID="0" />
          <CustomProperty Name="ASCII Folder" Value="\\abc\cdf\aaaa" FilterID="0" />
          <CustomProperty Name="Delimiter" Value="CommaQuote" FilterID="0" />
          <CustomProperty Name="Duplicate Handling" Value="Replace if Dup" FilterID="0" />
          <CustomProperty Name="EMAILATTDOC" Value="1" FilterID="0" />
          <CustomProperty Name="EMAILATTINDEX" Value="0" FilterID="0" />
          <CustomProperty Name="EMAILOUTBODY" FilterID="0" />
          <CustomProperty Name="EMAILOUTCC" FilterID="0" />
        </CustomProperties>
      </node02>
    </node02s>    
  </node01>  
</testing>

I need to get each CustomProperty under each node02. this is my code.

XDocument configparentXML = XDocument.Load("admin.xml");
string node = "node02";

var batchClasses = from batchClasse in configparentXML.Descendants(node)
                   select new ReadingXmlWithLinq
                   {
                       BatchClassName = batchClasse.Attribute("Name") != null ? batchClasse.Attribute("Name").Value : "",
                   };

foreach (var lv0 in batchClasses)
{
    node = "CustomProperty";
    var CustomProperties = from CustomProperty in configparentXML.Descendants(node)                                       
                           select new ReadingXmlWithLinq
                           {
                               CustomPropertyName = documentClasse.Attribute("Name") != null ? documentClasse.Attribute("Name").Value : ""
                           };
}

But in hear its return all CustomPropery Values. How can i get CustomerPropery for a node02 ?

Thank you very much.

  • 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-23T07:10:56+00:00Added an answer on May 23, 2026 at 7:10 am

    I’d approach this with XPath:

    var xmlString = @"<testing>...</testing>";
    var doc = XDocument.Parse(xmlString);
    var nav = doc.CreateNavigator();
    var path = "/testing/node01/node02s/node02/CustomProperties/CustomProperty";
    var nodeIterator = nav.Select(path);
    var nodes =
        nodeIterator
            .Cast<XPathNavigator>()
            .Select(n=>XElement.Parse(n.OuterXml));
    

    EDIT

    To get all nodes under (say) <node02 name="2"> you could alter the path as follows:

    var path=
       "/testing/node01/node02s/node02[@name=2]/CustomProperties/CustomProperty";
    

    Here’s a page of XPath examples so you can see what’s possible.

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

Sidebar

Related Questions

I have an xml like the following <DataCollection> <Data> <Name>John</Name> <Age>30</Age> </Data> ... more
I have XML with a value like the following: <products> <product id=1 name=All Products>
I have an XML file which looks like the following: <a> ...... <b> <c>
I have something like the following (shown below) defined in my styles.xml file. But
I can't seem to figure this one out. I have the following XML file:
I have the following XML: <A> <B> <C Since=2011-09-26T11:12:41.1383089Z> <E Name=One AnotherDate=2011-09-26T10:54:05.7025781Z/> <E Name=Two
I have an XML document which contains nodes like following:- <a class=custom>test</a> <a class=xyz></a>
If I have some xml containing things like the following mediawiki markup: ...collected in
I have a simple xml document that looks like the following snippet. I need
I have the following xml I'd like to deserialize into a class <?xml version=1.0

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.