XML file read and write summary

Source: Internet
Author: User

A period of time to participate in a project, to use the XML file read and write, but they did not use the XML file, how to read and write, with the set to read and write, a time of brain confusion, do not know how to do, and then through the guidance of others, in the Internet to find some open source library, slowly a library of a library

TinyXML: This library is the first open source Library, can be downloaded to the Internet, about the use of the library, there are a lot of blogs on the web, I do not repeat here, source download site: http://www.grinninglizard.com/tinyxml/, About the parsing of XML files, I also read someone else to write the blog know, specific reference address: http://blog.csdn.net/weiqubo/article/details/6913260, in fact, read and write very simple, summed up their own problems, Because I am involved in this project is involved in the XML file very large on hundreds of megabytes or several gigabytes, so you need to mainly consider memory, speed. TinyXML package is very good, object-oriented relatively strong, the biggest problem is that the library can not read hundreds of megabytes of files, as to the specific is greater than how many megabytes can not read, specifically no test, with a 20MB XML file, can read normally, but very slow, it takes about 10 minutes to traverse the end. You can't read it when you test with a 150MB XML file. So when I wrap up the functions I need, I'm going to have to re-select the library and re-write the code when he tests it.

Summary: In the use of an open source library, when you are not sure you need the function he can achieve, do not worry about the function, do not worry about the function of the library, first do the design of each module, specifically testing their own use of this library, when the library in memory, speed, And so on all important aspects can achieve their own requirements when the use of this library, thus reducing a lot of capacity.

CMarkup: This library is not a problem, is not very convenient, package is not very good, if you want to read a smaller XML file, or recommend using TinyXML, and speed is not as fast as rapidxml, the library can read 150MB XML file, The larger XML is not measured, and is not sure if it can be used

Rapidxml: Speed is faster, can read about 150MB XML file, used up also OK, but still no tinyxml easy to use

The process of reading XML files does not involve the encoding problem of XML files, memory is similar, is the final measurement of the rapidxml of the wasted indeed very quickly. In fact, for the XML file read the same way, as long as it will use a library, almost will be used, but the Open Source Library encapsulation method is not the same, the interface is not the same.

Data storage: After reading the XML file, the XML file will be read the data is initially stored with a map, and finally feel that the map is slower, instead of hash_map, but I use the VC6 no hash_map, so instead of vs2005 Before the map with the CString as the keyword, this does not work in the HashMap, HashMap does not support CString, this is the Internet to find out, wasted a lot of time, and CString changed to string.

Hair version: Near the time I am still running with Debug version, but 150MB of data to use almost 2.5 hours to run, then others said to run with release version to try, with release version of a run, used for 10 minutes or so, really surprised, Although it was also known that the release version is issued release, but I have never tested the debug version and release version of the efficiency comparison, the release version is optimized a lot, but as far as the optimization of the set, or need to run slowly learning, research ...

Study in ...

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.