Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] removing excess XML tags
From: Paul Heil (paul.heil_at_[hidden])
Date: 2009-02-05 17:10:57


On Thu, Feb 5, 2009 at 2:47 PM, Robert Ramey <ramey_at_[hidden]> wrote:

> Make your own archive derived from xml_?archive.
>
> Robert Ramey
>
> "Paul Heil" <paul.heil_at_[hidden]> wrote in message
> news:2fc4ff370902051118v6b811275rdad4dd46c04d40c9_at_mail.gmail.com...
> I'd like to use the boost::serialization library to generate XML that must
> be read by a third party application. Unfortunately, this application does
> not like the extra stuff that the serialization library generates.
>
> The code below generates XML that looks like this:
> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
> <!DOCTYPE boost_serialization>
> <boost_serialization signature="serialization::archive" version="5">
> <MYTAG class_id="0" tracking_level="0" version="0"></MYTAG>
> </boost_serialization>
>
> What I need is XML that looks more like this:
> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
> <MYTAG></MYTAG>
>
>
> What can I do to eliminate the extra stuff?
>
> Thanks,
> PaulH
>
> class MyClass
> {
> private:
> friend class boost::serialization::access;
>
> template<class Archive>
> void serialize(Archive &ar, const unsigned int version){};
>
> public:
> MyClass(){};
> friend std::ostream & operator<<(std::ostream &os, const MyClass &gp);
> virtual ~MyClass(){};
> };
>
> int main( int argc, _TCHAR* argv[] )
> {
> MyClass mc;
>
> std::ofstream ofs("MyFile.xml");
> boost::archive::xml_oarchive oa(ofs);
> oa << boost::serialization::make_nvp( "MYTAG", mc );
>
> return 0;
> }
>
> ------------------------------
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

That looks like the right way to go if I'm going to use Boost.Serialize to
do this. I guess I was hoping I was just missing a flag or something easy.
I'm not really looking to re-implement that much stuff.

Thanks



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net