Open renu555 opened 8 years ago
Yes, you do. The declaration will not be added to the document structure until you add it explicitly. The test project contains an example (search for NewDeclaration()
call).
Thanks. While porting to tinyxml2, apart from changes of namespace and class name, if there is possibility of more changes like these , I think a porting document can be helpful.
Since I am porting my application to tinyxml2, I can work on this ,if you think it can be helpful to others. @Dmitry
Well, I cannot comment on this, I never saw any code for earlier tinyxml. Perhaps @leethomason has some ideas.
It's been so long since I ported over...I've sort of forgotten the stumbling blocks. Should have documented it then.
I would like to address some issues in the Readme: the TinyXML-1 vs. 2 part is pretty outdated (there is no reason to use TinyXML-1 any more.) If you had a brief list of porting notes, it could go in the readme, and replace much of the existing 1 vs. 2 discussion.
Also a good issue to remember to more aggressively deprecate TinyXML-1. That version should be fully retired.
I'm doing this now :-(
Most of it seems pretty straightforward - xDoc.NewXYZ instead of new XYZ. ToElement() instead of Element(), create a XMLPrinter to export an object to text, etc.
The stumbling blocks come with the lack of Clone(), and the missing index parameters on Child().
The big warning is that XMLDocument.Parse returns the opposite of what it used to - 0 is now good, 0 in tinyXML1 was bad.
Clone() is problematic; although writing a DeepClone() is on the list. (But still doesn't work quite the same.)
The Child() index is (of course) fixable - it's just such a performance stumbling block.
And Parse()...yeah. Sorry about that. But didn't want to keep persisting the irregularity.
It was said earlier: --Since I am porting my application to tinyxml2, I can work on this ,if you think it can be helpful to others. @dmitry --Well, I cannot comment on this, I never saw any code for earlier tinyxml. Perhaps @leethomason has some ideas.
I would very much appreciate a porting guide. I am struggling with the various API changes, such as XMLDeclaration. At the very least I think that there should be a prominent statement that there are significant API differences - it is not a drop-in replacement.
I came here looking for an answer to the XMLDeclaration question, but since there isn't one:
XMLDocument doc;
XMLDeclaration* decl = doc.NewDeclaration();
doc.LinkEndChild(decl);
In Tinyxml creating a declaration was like : TiXmlDeclaration xmlDecl = new TiXmlDeclaration("1.0", "UTF-8", ""); But in Tinyxml2 it requires to create a document first tinyxml2::XMLDeclaration decl = doc.NewDeclaration(); decl->SetValue("xml version=\"1.0\" encoding=\"\"");
In tinyxml2, Do I need to do InsertEndChild after creating a new declaration?