Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

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
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
    Schema definition here
    <element>
        <id>1</id>
        <datafield1>xxxx</datafield1>
        <datafield2>xxxx</datafield2>
        ....
    </element>
    <element>
        ....
</NewDataSet>


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

Any help is greatly appreciated

Cheers
Posted
Comments
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.
Max Vagner 31-Oct-12 4:34am    
What are you using to read XML? Is file located locally? Try System.Xml.Linq.XElement.Load()

Try specifying XmlReadMode, this would increase performance.

C#
myDS.ReadXml("C:\\Test\\input.xml", XmlReadMode.ReadSchema);
 
Share this answer
 
Comments
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.
Hi,
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.

C#
foreach (DataTable dataTable in dataSet.Tables)
   dataTable.BeginLoadData();

dataSet.ReadXml("file.xml"); 

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


More details and source of the above code is MSDN at http://msdn.microsoft.com/en-us/library/fx29c3yd.aspx[^]

Hope that helps

- Milind
 
Share this answer
 
Comments
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900