tinyxml2简介:
tinyxml2是一个c++xml解析器,它非常高效,而且非常的小,可以很好地嵌入到其他的程序,几乎可以在所有场景运用(我的经验来看)
tinyxml2简单读取
我们先写一个xml文本如下
test.xml
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<one>
<two color = "#CC00FF">this is a Sentence</two>
</one>
</xml>
我们对于tinyxml2的运用只需要加入一个头文件就行了
#include "tinyxml2.h"
tinyxml2::XMLDocument docs;
docs.LoadFile("test.xml");
log("example 1by1 -- doc.ErrorID() ===%d", docs.ErrorID());
if (docs.ErrorID() == tinyxml2::XMLError::XML_SUCCESS)
{
tinyxml2::XMLElement* titleElement = docs.FirstChildElement("one")->FirstChildElement("two");
const char *cstr_x = titleElement->G