c++tinyxml2

how to make user enter the path of the xml file in tinyxml2


How i can make the user enter the path of the xml file to be saved?

I want the user to enter something like "c:\test.xml" and the xml file is generated by that name and location.

I tried

 string PathName;
 cin >> PathName;
XMLDocument doc;
doc.SaveFile(PathName);

but it gives me the error

 no instance of overloaded function matches the argument list 

I know its such a simple question but somehow I am stuck, sorry


Solution

  • I think your error is telling the parameter type doesn't match an overload. Try this instead:

    auto result = doc.SaveFile(PathName.c_str());
    

    Edited to include result from the function - if it fails it should give you an error code. Quoting the docs:

    Save the XML file to disk. Returns XML_SUCCESS (0) on success, or an errorID.