Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7688421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:55:00+00:00 2026-05-31T19:55:00+00:00

I wanted to serialize objects with XML, so I got TinyXML. However I went

  • 0

I wanted to serialize objects with XML, so I got TinyXML. However I went with the newer TinyXML2. Problem is, I can’t find a tutorial anywhere, so I just read the documentation. However, I seem to be stuck with adding an element to the document.

Could someone tell me what is wrong with my code?

Here’s my demo.xml file contents:

<?xml version="1.0" ?>
<Hello>World</Hello>

here’s my main() method:

#include "tinyxml2/tinyxml2.h"
using namespace tinyxml2;

int main (int argc, char * const argv[]) 
{
   XMLDocument doc;
   if (doc.LoadFile("demo.xml") == XML_SUCCESS)
   {
      XMLNode *node = doc.NewElement("foo");
      doc.InsertEndChild(node);
      doc.SaveFile("demo2.xml");
   }
}

and finally, here’s the demo2.xml file:

<?xml version="1.0" ?>
<Hello>World</Hello>

<foo/>

Foo should look like this: <foo></foo>

But it doesn’t for some reason. Can anyone explain why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:55:01+00:00Added an answer on May 31, 2026 at 7:55 pm

    In fact, it shouldn’t look like that. You don’t put any data “in between” your <foo>...</foo> tags. As such <foo/> (note the slash) is a correct representation of what you have.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've always wanted to send objects that you can serialize in XML across websites,
I wanted to serialize a java class to XML with XStream. I needed to
Can I serialize a generic list of serializable objects without having to specify their
Just wanted to know if anyone is really using Objects and Collections in Oracle
I've been working with Xml Serialization/Deserialization in .net and wanted a method where the
Is there a jQuery plugin out there that can serialize a form, and then
I simply wanted to serialize all the fields of a submitted form, like this
Wanted to know if someone had a suggestion on code or maybe there's a
Wanted to see if anyone knows how to add props to a image with
Wanted to understand the difference between undef and define a macro as 0. Thanks.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.