Click here to Skip to main content
13,050,606 members (89,187 online)
Rate this:
Please Sign up or sign in to vote.
See more:

Now before I start explaining my issue, I have read a few articles about issues reading XML files over a GB in size. That is not my issue, or so I believe.

I have two XML files, both about 4MB in size, file A with roughly 10000 elements, file B with 1500. The specific elements are differing in size.

Now quite bizarrely file A takes a fraction of a second to be read using DataSet.ReadXML and yet file B takes over two minutes!

Any one found anything like this before? Am I missing something obvious?

The structure of the XML files is thus

<?xml version="1.0" standalone="yes"?>
    Schema definition here

I apologise if my use of the term 'element' is incorrect, alas I am a self-taught C# coder.

Any help is greatly appreciated

Posted 27-Oct-12 14:07pm
John_Black 27-Oct-12 22:29pm
Something I have noticed is that my application is significantly quicker when compiled.

Reading the specific xml file only seems slow when running the app within Visual Studio Express either in debug or release mode.
Skywithin 31-Oct-12 4:34am
What are you using to read XML? Is file located locally? Try System.Xml.Linq.XElement.Load()
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Try specifying XmlReadMode, this would increase performance.

myDS.ReadXml("C:\\Test\\input.xml", XmlReadMode.ReadSchema);
John_Black 27-Oct-12 22:22pm
Thanks for your quick response, however your suggestion made no change in the speed of the ReadXML command unfortunately.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Since you are saying both the files are around 4 MB, but one has 10000 elements whereas second has 1500 elements, I assume, the structure is different which might be causing multiple table reading.

You may like to try calling BeginLoadData before calling ReadXml method.

foreach (DataTable dataTable in dataSet.Tables)
foreach (DataTable dataTable in dataSet.Tables)

More details and source of the above code is MSDN at[^]

Hope that helps

- Milind
John_Black 28-Oct-12 13:58pm
Hi Milind, thanks for response.

However I have already tried that without success.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 28 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100