pugixml: Cannot get children/cannot iterate

dead_man

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