tinyxml2

tinyxml2: Difference between doc.Print() and doc.SaveFile()


I just asked myself if there are any differences between saving a file via doc.Print() and doc.SaveFile() in tinyxml2.

Here is a quick example:
Let's say we have a filepointer and a XML document from where we get our data.

FILE filepointer("MyFile.xml", "rb") //empty file
XMLDocument doc;
doc.LoadFile("SourceFile.xml")       //file we extract data from

Now we have two options to save the file.

XMLPrinter printer(filepointer)
doc.Print(&printer)

vs

doc.SaveFile(filepointer)

Are there any differences in these approaches?


Solution

  • SaveFile just does a Print internally, see https://github.com/leethomason/tinyxml2/blob/c0ff869500f3d2b828eeefc725a5bc1ff9b844f0/tinyxml2.cpp#L2247