Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Porting from tinyxml to tinyxml2 #398

Open
renu555 opened this issue Dec 3, 2015 · 10 comments
Open

Porting from tinyxml to tinyxml2 #398

renu555 opened this issue Dec 3, 2015 · 10 comments

Comments

@renu555
Copy link
Contributor

renu555 commented Dec 3, 2015

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?

@Dmitry-Me
Copy link
Contributor

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).

@renu555
Copy link
Contributor Author

renu555 commented Dec 3, 2015

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.

@renu555
Copy link
Contributor Author

renu555 commented Dec 3, 2015

Since I am porting my application to tinyxml2, I can work on this ,if you think it can be helpful to others. @dmitry

@Dmitry-Me
Copy link
Contributor

Well, I cannot comment on this, I never saw any code for earlier tinyxml. Perhaps @leethomason has some ideas.

@leethomason
Copy link
Owner

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.

@leethomason
Copy link
Owner

Also a good issue to remember to more aggressively deprecate TinyXML-1. That version should be fully retired.

@gbjbaanb
Copy link

gbjbaanb commented Jul 20, 2016

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.

@leethomason
Copy link
Owner

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.

@marlowa
Copy link

marlowa commented Apr 1, 2022

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.

@parsley72
Copy link

parsley72 commented Oct 19, 2022

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants