Search code examples
c++tinyxml2

How to use absolute paths with TinyXML2


I am using TinyXML2 to load/edit/save xml settings.

I have found this works: (success == true)

tinyxml2::XMLDocument *printjobxml;
printjobxml = new tinyxml2::XMLDocument();
success = printjobxml->LoadFile("myxml.xml");

...and this doesn't: (success always == false)

tinyxml2::XMLDocument *printjobxml;
printjobxml = new tinyxml2::XMLDocument();
success = printjobxml->LoadFile("C:\\myxml.xml");

The only difference being the absolute path instead of relative.

What am I doing wrong?


Solution

  • XMLDocument::LoadFile() return XML_NO_ERROR (0) on success, so the second example is works fine, but the first is not. I bet the first LoadFile() call returns XML_ERROR_FILE_NOT_FOUND (3).