In my previous blog, I mentioned parsing xml as a real java program. The xml parsing methods in java include dom and sax. I am used to dom. When c ++ first came into contact with xml, I must use inertia and Lenovo thinking.
There are many xml parsing methods in c ++. Here, I would like to explain the simplest and most convenient tinyxml method as convenient as Dom.
TinyXML is an open-source parsing XML library that can be used in C ++ and compiled in Windows or Linux. The parsing library's model parses the XML file and then generates the DOM model in the memory, so that we can easily traverse this XML tree.
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.
By looking at the source code, you can query the classes required in TinyXML and the relationships between classes. By understanding this, we can make development easier.
The relationships between classes are as follows:
Understanding the relationship between them not only facilitates development, but also solves the following questions about tinyxml.
Usage: Download The tinyxml source code or corresponding dll on the official website. During development, I use the tinyxml source code, which is very convenient. We recommend that you use the tinyxml source code. You only need to import tinyxml. h, tinystr. h, tinystr. cpp, tinyxml. cpp, tinyxmlerror. cpp, and tinyxmlparser. cpp into the project to use it.
In the next blog, we will operate xml based on tinyxml.