I am using pugixml for the first time and I am not able to correctly load a file into memory.
My XML test document:
<?xml version="1.0"?>
<node>
</node>
I use following code to load the document and get the child:
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);
}
Output:
XML [test.xml] parsed without errors
it does not work
XML file after execution:
<?xml version="1.0"?>
(When using doc.save_file function data are lost)
Compiler: MS Visual Studio 2010 Ultimate
Language: C++
Build: UNICODE/x64