From: http://www.cnblogs.com/joaen/archive/2005/07/01/184776.html
XML reading is always done through the readxml method of dataset, and other attributes are not used. When the data volume is small, it is still safe. It is not until today that a 20 m XML Stream is read that it affects efficiency.
By default, the xmlreadmode. Auto method is used to read readxml by default. The previous method is used because the XML file does not contain
Scheme and dataset first deduce the XML structure and then load the data. However, we can infer the structural efficiency of a 20 m stream. If xmlreadmode is
For members other than auto and inferschema (also inferred based on data), the content will be ignored except for the number of rows.
How can we solve this annoying problem? In fact, it is easy to provide Schema (readxmlschema method) for dataset, and set xmlreadmode to ignoreschema. TestedThe processing time is increased from several minutes to several seconds.Example:
1 Dataset DS = New Dataset ();
2 Using (Stringreader SR = New Stringreader (XXX ))
3 {
4DS. readxmlschema (SR );
5}
6 DS. Tables [ 0 ]. Beginloaddata ();
7
8
9 Using (Stringreader SR = New Stringreader (XXX ))
10 {
11DS. readxml (Sr, xmlreadmode. ignoreschema );
12}
13 DS. Tables [ 0 ]. Endloaddata ();