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 6778631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:17:19+00:00 2026-05-26T16:17:19+00:00

I am adding the ability to save as XML to several native C++ classes.

  • 0

I am adding the ability to save as XML to several native C++ classes. I am looking for something in C++ that performs the same job as XmlConvert from .Net.

double d = 45.5454545;
xmlWriter.WriteAttributeAtring(XmlConvert.ToString(d));
  • 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-26T16:17:19+00:00Added an answer on May 26, 2026 at 4:17 pm

    Consider using boost XML serilization.

    #include <fstream>
    #include <iostream>
    #include <boost/archive/xml_iarchive.hpp>
    #include <boost/archive/xml_oarchive.hpp>
    
    using namespace std;
    
    class Test {
    private:    
        friend class boost::serialization::access;
        template<class Archive> void serialize(Archive & ar,
                const unsigned int version) {
            ar & BOOST_SERIALIZATION_NVP(a);
            ar & BOOST_SERIALIZATION_NVP(b);
            ar & BOOST_SERIALIZATION_NVP(c);
        }
    
        int a;
        int b;
        float c;
    public:
        inline Test(int a, int b, float c) {
            this->a = a;
            this->b = b;
            this->c = c;
        }
    };
    
    int main() {
        std::ofstream ofs("filename.xml");
    
        Test* t = new Test(1, 2, 3.3);
    
        boost::archive::xml_oarchive oa(ofs);
        oa << BOOST_SERIALIZATION_NVP(t);
    
        return 0;
    }
    

    If using boost is out of question you can simply borrow the idea provided your objects are very simple and don’t have references to each other.

    1. Create a XMLDocument
    2. Each of your class has a Serialize(XMLDocument*) method
    3. In their Serialize method they update XMLDocument with the members.

    Unfortunately C++ doesn’t have reflection is it impossible to do serialization easily without handling each class.

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

Sidebar

Related Questions

When adding new properties to classes, I find myself typing the same things over
I have a number of classes that contain the ability to be written to
I'm adding the ability to share scores from my app using android's share intent:
I am adding the ability for users of my web app to get credit
When adding a DLL as a reference to an ASP.Net project, VS2008 adds several
I am having difficulties adding the ability for a user to send a support
In my chat app, I am adding the ability to log chats. The logs
Adding the foursquare check-in ability to an existing app has raised some questions. Mainly,
I was asked to build a java system that will have the ability to
Does zepto.js have a method for adding classes and extending with subclasses? A connected

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.