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

The Archive Base Latest Questions

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

I have a large xml file and want to get a defined number of

  • 0

I have a large xml file and want to get a defined number of <Cooperation> nodes from it. What’s the best way to handle this.

Currently, I’m using this code

public string FullCooperationListChunkGet(int part, int chunksize)
{
    StringBuilder output_xml = new StringBuilder();
    IEnumerable<XElement> childList = from el in xml.Elements("Cooperations").Skip(part * chunksize).Take(chunksize) select el;

    foreach (XElement x in childList.Elements())
    {
        output_xml.Append(x.ToString());
    }

    return output_xml.ToString();
}

Skip(part * chunksize).Take(chunksize) doesn’t work (seems to be only valid for the Cooperations Tag and not the Cooperation Tags)

Can somebody point me in the right direction.

Thanks,
rAyt

Edit:
The Background is this: I’m pushing these xml parts via a webservice to a Blackberry. Unfortunately, the http request size on a blackberry enterprise server is limited
to 256 kb by default.

Part of the XML File:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Cooperations>
  <Cooperation>
    <CooperationId>xxx</CooperationId>
    <CooperationName>xxx</CooperationName>
    <LogicalCustomers>
      <LogicalCustomer>
        <LogicalCustomerId>xxx</LogicalCustomerId>
        <LogicalCustomerName>xxx</LogicalCustomerName>
        <Customers>
          <Customer>
            <CustomerId>xxx</CustomerId>
            <CustomerName>xxx/CustomerName>
          </Customer>
          <Customer>
            <CustomerId>xxx</CustomerId>
            <CustomerName>xxx</CustomerName>
          </Customer>
        </Customers>
      </LogicalCustomer>
      <LogicalCustomer>
        <LogicalCustomerId>xxx</LogicalCustomerId>
        <LogicalCustomerName>xxx</LogicalCustomerName>
        <Customers>
          <Customer>
            <CustomerId>xxx</CustomerId>
            <CustomerName>xxx</CustomerName>
          </Customer>
          <Customer>
            <CustomerId>xxx</CustomerId>
            <CustomerName>xxx</CustomerName>
          </Customer>
        </Customers>
      </LogicalCustomer>
      <LogicalCustomer>
        <LogicalCustomerId>xxx</LogicalCustomerId>
        <LogicalCustomerName>xxx</LogicalCustomerName>
        <Customers>
          <Customer>
            <CustomerId>xxx</CustomerId>
            <CustomerName>xxx</CustomerName>
          </Customer>
        </Customers>
      </LogicalCustomer>
    </LogicalCustomers>
  </Cooperation>
  <Cooperation>
  ...
  • 1 1 Answer
  • 2 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-12T07:19:55+00:00Added an answer on May 12, 2026 at 7:19 am

    For using XDocument, I expect you want something like:

    var qry = doc.Root.Elements("Cooperation").Skip(part*chunksize).Take(chunksize);
    

    however, if the data is large, you might have to drop down to XmlReader instead… I’ll try to do an example… (update; 512kb probably isn’t worth it…)

    The problem with your code is that you are using .Elements() here:

    foreach (XElement x in childList.Elements())
    {
        output_xml.Append(x.ToString());
    }
    

    Just remove that:

    foreach (XElement x in childList)
    {
        output_xml.Append(x.ToString());
    }
    

    For info – you are also using query syntax unnecessarily:

    IEnumerable<XElement> childList = from el in xml.Elements("Cooperations")
        .Skip(part * chunksize).Take(chunksize) select el;
    

    is 100% identical to:

    IEnumerable<XElement> childList = xml.Elements("Cooperations")
        .Skip(part * chunksize).Take(chunksize);
    

    (since the compiler ignores an obvious select, without mapping it to the Select LINQ method)

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

Sidebar

Related Questions

I have a large XML file (3000+ nodes) that I want to represent in
I have this large XML file. There is a field that I want to
I want to parse a large XML file and I have two options: Perl
I have a large xml file that looks like this: 20120124 07:30:15.301, saving to
i have a extremely large xml-file - which is derived from the field of
Question We have a large number of xml configuration files that we want merged
I have a large XML file ( around 1mb ) . i want to
I have a large xml file (approx. 10 MB) in following simple structure: <Errors>
I have a large XML file which in the middle contains the following: <ArticleName>Article
I have a large XML file (many MBs) that I cannot afford to download

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.