Loading dataset from XML

  • Thread starter Thread starter kids_pro
  • Start date Start date
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
 
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
 
Back
Top