Efficiency of reading XML via Dataset

Source: Internet
Author: User

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 ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.