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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:13:55+00:00 2026-06-07T00:13:55+00:00

I have a problem that I’m working on for quite some time now. I

  • 0

I have a problem that I’m working on for quite some time now. I have an XML file with over 50000 records (one record has 3 levels). This file is used by one of my applications to control document sending (the record holds, among other informations, the type of document that has to be sent to a certain person). So in my application I load the XML file into a XmlDocument, and then by using SelectNodes method, I create a XmlNodeList from which I read the data I want. The process is like this – our worker takes the persons ID card (simple eith barcode) and reads it with barcode reader. When the barcode value has been read, my application finds the person with that ID in the XML file, and stores the type of the document into a string variable. Then the worker takes the document and reads its barcode, and if the value of documents barcode and the value in the value in the string variable match, the application makes a record that document of type xxxxxxxx will be sent to the person with ID yyyyyyyyy. This is very simple code, it works perfectly for now, and this is how it looks:
On textBox1_TextChanged event (worker read persons ID):

foreach(XmlNode node in NodeList){
if(String.Compare(node.Attributes.GetNamedItem("ID").Value.ToString(),textBox1.Text)==0)
{
 ControlString = node.ChildNode[3].FirstChild.Attributes.GetNamedItem("doctype").Value.ToString();
 break;
}
}
textBox2.Focus();

And on textBox2_TextChanged event (worker read the documents barcode):

if(String.Compare(textBox2.Text,ControlString)==0)
{
//Create a record and insert it into a SQL database
}

My question is – how will my application perform with larger XML files (I was told that the XML file might be up to 500,000 records large), will this approach be valid, or will I need to cut the file into smaller files. If I have to cut it, please give me an idea with some code samples, I’ve tried to do it like this:
Reading entire record and storing it into a string:

private void WriteXml(XmlNode record)
        {
            tempXML = record.InnerXml;
            temp = "<" + record.Name + " code=\"" + record.Attributes.GetNamedItem("code").Value + "\">" + Environment.NewLine;
            temp += tempXML + Environment.NewLine;
            temp += "</" + record.Name + ">";
            SmallerXMLDocument += temp + Environment.NewLine;
            temp = "";
            i++;
        }

tempXML, temp and SmallerXMLDocument are all string variables.

And then in button_Click method I load the XML file into a XmlNodeList (again by using XmlDocument.SelectNodes method) and I try to create one big string value that would hold all records like this:

foreach(XmlNode node in nodes)
{
 if(String.Compare(node.ChildNode[3].FirstChild.Attributes.GetNamedItem("doctype").Value.ToString(),doctype1)==0)
{
  WriteXML(node);
}
}

My idea was to create a string value (in this case called SmallerXmlDocument), and when I pass trough the entire XML file, to simply copy the value of that string into a new file. This works, but only for files that have up to 2000 records (and my has way more than that). So, if I need to cut the file into smaller pieces, what would be the best way to do it (keep in mind that there could be up to half a million records in a XML file)?

Thanks

  • 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-07T00:13:56+00:00Added an answer on June 7, 2026 at 12:13 am

    First off, I suspect you’re abusing the XML API. You can query the XmlDocument directly with XPath to get your result straight away, without first selecting a list of records and iterating over them. At no point should you need to convert parts of the XML tree to strings.

    The approach of loading the entire XML document into memory will work just fine as long as you don’t mind spending 50 to 500 megabytes of RAM on your application.

    If you want to save RAM you should use XmlReader to stream the XML from disk.

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

Sidebar

Related Questions

this is my regex for digital dnumbers: \d+(.\d+)+(,\d+) but now i have problem that
I have a problem that i've struggled with for a long time. This problem
I have one problem that I can't explain. Here is the code in main
I have this problem that my .php file is presented as clear text in
i have this problem that i can't solve for days now...here is my code.
I have a Java problem that involves reading a text file and check that
I have a problem that i have a dynamic field in schema.xml as <dynamicField
I have a problem that one of my activities is popping out after I
In a couple of scripts that I use I have problem that is intermittent.
(I have a problem that I illustrated in this question but had no correct

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.