官网:http://pugixml.org/
pugixml解析库下载:点击打开链接
测试案例:
xml文件
<?xml version="1.0"?>
<mesh name="mesh_root">
<node attr1="天策"/>
<node attr1="北京海淀区" attr2="value2" >
<innernode name="d"/>
</node>
<xxx>hello</xxx>
</mesh>
cpp文件
// ConsoleApplication4_pugixml_test.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "windows.h"
#include "pugixml.hpp"
#include <iostream>
using namespace pugi;
int main(int argc, char* argv[])
{
xml_document doc;
xml_parse_result result = doc.load_file("tree.xml",parse_full, encoding_utf8);
xml_node xnode = doc.child("mesh").first_child();
while (xnode.empty() == false)
{
if (strcmpi(xnode.name(), "node") == 0)
{
printf("%s\n", xnode.attribute("attr1").value());
}
xnode = xnode.next_sibling();
}
getchar();
return 0;
}