0
我第一次使用pugixml,我无法将文件正确加载到内存中。pugixml:无法获取孩子/无法迭代
我的XML测试文档:
<?xml version="1.0"?>
<node>
</node>
我用下面的代码加载文档,并得到孩子:
pugi::xml_document doc;
pugi::xml_parse_result result = doc.load("test.xml");
if (result)
{
Log(L"XML [%s] parsed without errors", L"test.xml");
pugi::xml_node node = doc.child(L"node");
if (node)
Log(L"it works");
else
Log(L"it does not work");
doc.save_file(L"test.xml");
}
else
{
Log(L"XML [%s] parsed with errors", L"test.xml");
Log(L"XML Error description: %s", result.description());
Log(L"XML Error offset: %d", result.offset);
}
输出:执行后
XML [test.xml] parsed without errors
it does not work
XML文件:
<?xml version="1.0"?>
(当使用doc.save_file函数数据丢失)
编译器:MS的Visual Studio 2010终极
语言:C++
体形:UNICODE/X64