Loading dataset from XML

K

kids_pro

I had come across a code block from Loading a DataSet from XML (.NET
Framework Developer's Guide)
----------------------------------------
NOte If you call ReadXML to load a very large file, you may encounter slow
performance. To ensure best performance for ReadXml, on a large file, call
the DataTable.BeginLoadData method for each table in the DataSet, then call
ReadXml. Finally, call DataTable.EndLoadData for each table in the DataSet
as shown in the following example.

DataSet ds = new DataSet();

// How do I know how many table since I haven't load the XML data yet.
foreach(DataTable t in ds.Tables)
t.BeginLoadData();


ds.ReadXml("dotNET.xml");


// Here okay I may know how many table since I loaded the XML data.
foreach(DataTable t in ds.Tables)
t.EndLoadData();

How can this code improve reading large XML performance?


Cheers,
Kids
 
Z

Zürcher See

kids_pro said:
I had come across a code block from Loading a DataSet from XML (.NET
Framework Developer's Guide)
----------------------------------------
NOte If you call ReadXML to load a very large file, you may encounter slow
performance. To ensure best performance for ReadXml, on a large file, call
the DataTable.BeginLoadData method for each table in the DataSet, then call
ReadXml. Finally, call DataTable.EndLoadData for each table in the DataSet
as shown in the following example.

DataSet ds = new DataSet();

// How do I know how many table since I haven't load the XML data yet.
ds.ReadXml("dotNET.xml",System.Data.XmlReadMode.ReadSchema);


foreach(DataTable t in ds.Tables)
t.BeginLoadData();


ds.ReadXml("dotNET.xml");


// Here okay I may know how many table since I loaded the XML data.
foreach(DataTable t in ds.Tables)
t.EndLoadData();

How can this code improve reading large XML performance?


Cheers,
Kids
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top