官网和下载地址
http://github.com/zeux/pugixml/releases/download/v1.9/pugixml-1.9.zip
不废话,直接上文档中的例子吧!! 从文档中加载xml文件,另外这个解析类很强大,
支持xpath语法不懂的可以参考(http://www.w3school.com.cn/xpath/index.asp)
另外注意一点,在vs编译的时候需要将pugixml.cpp 去掉预编译!
//tree.xml
<?xml version="1.0"?>
<mesh name="mesh_root">
<!-- here is a mesh node -->
some text
<![CDATA[someothertext]]>
some more text
<node attr1="value1" attr2="value2" />
<node attr1="value2">
<innernode/>
</node>
</mesh>
<?include somedata?>
#include "pugixml.hpp"
#include <iostream>
int main()
{
// tag::code[]
pugi::xml_document doc;
pugi::xml_parse_result result = doc.load_file("tree.xml");
std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl;
// end::code[]
}
// vim:et