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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:04:39+00:00 2026-05-13T20:04:39+00:00

I have a large XML file (3000+ nodes) that I want to represent in

  • 0

I have a large XML file (3000+ nodes) that I want to represent in a TreeView on ASP.NET. I cannot databind it to a XMLDataSource because loading the TreeView will then be way too slow (I never even waited long enough to see it finish…)

So the solution for this would be to use the PopulateOnDemand property of the TreeNodes to load data only when needed. Problem is, I can’t think of a way to acheive this…

How can-I, based on the ID of a node, search a XMLDocument to get all the childnodes of the node having this ID?

XML would look like that:

<document ID=1>
    <document ID=2>
        <document ID=3>
        </document>
    </document>
    <document ID=4>
    </document>
</document>

There are nor rules on how much levels it can go down or anything…

  • 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-13T20:04:40+00:00Added an answer on May 13, 2026 at 8:04 pm

    From my own experience, adding 3000 nodes to an ASP.NET tree view is a bad thing to do, as the viewstate will go berserk … meaning it will explode and become really big!

    Try something with clientside Javascript (with JQuery for example) and AJAX requests to speed up loading. Using the MVC and the client side Javascript may also be an option.

    Also from experience, do not use MS Ajax to update the treeview, it is not supported.

    For reading XML Linq to XML might be an option that’s quire fast. Here you can find a sample for that.

    If you have to use System.Xml then the following code gets the child item for the given id from the document:

      XmlDocument document = new XmlDocument();
      XmlNodeList nodes = document.SelectNodes(string.Format("/descendant-or-self::*[@id = '{0}']/*", id));
      foreach (XmlNode child in nodes) {
        // child contains the child node
      }
    

    This works fine when you don’t have namespaces, otherwise, it gets a bit messy.

    Using Linq to XML the whole thing looks like this:

    XDocument doc = new XDocument();
    XElement root = doc.Root;
    IEnumerable<XElement> children = doc.Root
                                        .DescendantsAndSelf()
                                        .Where(x => (string) x.Attribute("id") == id)
                                        .SelectMany(x => x.Elements());
    foreach (var child in children) {
       // do something with the child
    }
    
    • 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 (many MBs) that I cannot afford to download
I have this large XML file. There is a field that I want to
I have a large xml file that looks like this: 20120124 07:30:15.301, saving to
I want to parse a large XML file and I have two options: Perl
I have a request that returns a large xml file. I have the file
I have a large xml file (40 Gb) that I need to split into
I have a very large XML file that I need to parse so I
I have several fairly large XML files that represent data exported from a system
I have a large XML file that looks like <data> skdfnlsniisimsoinfsdfoisdfinsdofinodnfonf <emrosem> 23324097234097g </emrosem>
I have a function, that gets a large XML file, then parses it, and

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.