Use tinyxml C ++ to read and write XML files

Source: Internet
Author: User

Tinyxml is a lightweight C ++ interpreter based on the DOM model.

The Dom model is a Document Object Model. It divides a document into multiple elements (such as books, chapters, sections, and segments ), the tree structure is used to represent the ordered relationship between these elements and the nested inclusion relationship.

The following is an XML snippet: <persons>
<Person
Id = "1">
<Name> Zhou Xingxing </Name>
<Age> 20 </age>
</Person>
<Person
Id = "2">
<Name> Bai Jingjing </Name>
<Age> 18 </age>
</Person>
</Persons>

In tinyxml, some classes are defined based on various elements of XML:

Tixmlbase: The base class of the entire tinyxml model.

Tixmlattribute: attribute corresponding to the element in XML.

Tixmlnode: corresponds to a node in the DOM structure.

Tixmlcomment: corresponding to the comment in XML

Tixmldeclaration: corresponds to the declarative part in XML, that is, <? Versiong = "1.0"?>.

Tixmldocument: corresponds to the entire XML document.

Tixmlelement: Elements corresponding to XML.

Tixmltext: text part corresponding to XML

Tixmlunknown: corresponds to the unknown part of XML.

Tixmlhandler: defines some XML operations.

Tinyxml is a parsing library mainly composed of Dom model classes (tixmlbase, tixmlnode, tixmlattribute, tixmlcomment, tixmldeclaration, tixmlelement, tixmltext, tixmlunknown) and Operation class (tixmlhandler. It consists of two header files (. h file) and four CPP files (. CPP file), when used, as long as (tinyxml. h, tinystr. h, tinystr. CPP, tinyxml. CPP, tinyxmlerror. CPP, tinyxmlparser. CPP) import the project to use it. If needed, you can call it as your own DLL.

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.