You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Actually my initial reaction is that the code should 1) save, 2) no error, and 3) yes, and the file produced is:
<?xml version="1.0" encoding="UTF-8"?>
But that would mean that a new document would be created with the encoding declaration. Which may be correct and would be replaced on load (to whatever is in the loaded file.) I'm a little concerned about breaking existing uses - specifically people who are adding the declaration by hand. So that's one meta question: should we insert that by default?
You question though is: what should we do now? I'd argue that the existing behavior is correct. The user created an empty XML file, saved it, and it resulted in an empty file. TinyXML-2 is being less helpful than it should, but I'm hesitant to introduce (more) behavior that conflicts with a future fix (if we create the encoding declaration.)
Thoughts? This is an edge case, but raises tricky issues about default behavior.
The empty cannot be loaded afterwards - that's why there's "empty.xml" in the testset. So the current implementation is happy to save an empty document but then will not load the result of such saving.
Spent some time looking at this. I acknowledge the bug; however, there are already test cases enforcing the asymmetric behavior. The only real answer I see is "injecting" the declaration and that's going to cause all sorts of trouble.
This code:
yields an empty file on disk and
XMLDocument::Error()
beingfalse
. Is that expected?The text was updated successfully, but these errors were encountered: