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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:32:15+00:00 2026-05-23T13:32:15+00:00

Appreciate some pointers on how can I use XPath on XML file to extract

  • 0

Appreciate some pointers on how can I use XPath on XML file to extract only some data and load it into a dataset.

ds.ReadXml(fsReadXml);

will load the entire xml into dataset but my requirement is to load only particular node and values to dataset.

Sample xml data:

<data cobdate="5 Jul 2011" DBStatus="">
  <view>BOTH</view>
  <show_acctnbr>true</show_acctnbr>
  <summary>
    <headings sum="Summary" real_per="Realized this period" real_trd="Profit/loss in trading currency" real_select="Profit/loss in selected currency" short_term="Short Term Profit/Loss" long_term="Long Term Profit/Loss" />
    <account number="A123456" curr_code="USD" curr_desc="US Dollars" tradecurrvalue="123,123.00" selectcurrvalue="123,123.00" managed="NO" />
    <account number="P123456" curr_code="USD" curr_desc="US Dollars" tradecurrvalue="0.00" selectcurrvalue="0.00" managed="NO" />
  </summary>
  <detail>
    <headings dateaq="Date acquired" datesld="Date sold" desc="Description" sec_nbr="Security number " qty="Quantity" cost="Cost basis" />
    <account number="A123456" currency="US Dollars">
      <item datesold="29 Apr 11" sec_nbr="1234" description="SOME VALUE(USD)" quantity="8,000" proceeds="123,123.0" />
      <item datesold="29 Apr 11" sec_nbr="4567" description="SOME VALUE(USD)" quantity="9,000" proceeds="123,123.0" />
    </account>
    <account number="P123456" currency="US Dollars">
      <item datesold="29 Apr 11" sec_nbr="1234" description="SOME VALUE(USD)" quantity="8,000" proceeds="123,123.0" />
      <item datesold="29 Apr 11" sec_nbr="4567" description="SOME VALUE(USD)" quantity="9,000" proceeds="123,123.00" />
    </account>
  </detail>
</data>

In this example data, I just need to load accounts from <summary> node and if possible only number, tradecurrvalue and selectcurrvalue attributes. I using C# and 3.5.

  • 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-23T13:32:15+00:00Added an answer on May 23, 2026 at 1:32 pm

    With XDocument:

    var doc = XDocument.Load(fileName);
    var lst = doc
           .Descendants("summary")   // don't care where summary is
           .Elements("account ")     // direct child of <summary>
           .Select(x => new 
           {
              number = x.Attribute("number").Value,
              ...
           });
    
    foreach(var account in lst) 
    {
      .... // add to DataSet
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a few problems with some Objective-C and would appreciate some pointers. So
G'Day, Is anyone able to provide some pointers on how I can notify my
I'd appreciate some feedback on a particular approach I'm thinking of using. The scenario
I would appreciate some guidance on modelling services and operations in WCF. I have
I have a design issue that I would appreciate some input on. I would
I appreciate that there are now many mechanisms in dotnet to deal with XML
It seems that StringListProperty can only contain strings up to 500 chars each, just
I am seeking pointers to assist the direction of my research into providing assessements
I have been searching on the web to see if I can use GoogleMaps
I would really appreciate any suggestions, no matter how simple or complex, to help

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.