Hi Sangeeta,
I get the same behavior as you do, but only if I don't let the
xml_oarchive go out of scope. If it goes out of scope, then the end tag
is written.
John
Sangeeta Singh wrote:
> Hi,
>
> When I xml serialize an object to a stringstream i get the following
> output
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
> <!DOCTYPE boost_serialization>
> <boost_serialization signature="serialization::archive" version="3">
> <bidResponse class_id="0" tracking_level="0" version="0">
> <oppId>69</oppId>
> <delay>0</delay>
> <bid class_id="1" tracking_level="0" version="0">
> <maxBid>5.3000002</maxBid>
> <minBid>5.3000002</minBid>
> <adBlob>adblob</adBlob>
> </bid>
> </bidResponse>
>
> As can be seen the end tag </boost_serialization> is missing. thi
> shappens even if I flush the stringstream.
>
> If i xml serialize to a text file I do not see this problem here is
> the o/p when I xml serialize to a text file
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
> <!DOCTYPE boost_serialization>
> <boost_serialization signature="serialization::archive" version="3">
> <bidRequest class_id="0" tracking_level="0" version="0">
> <oppId>34567889</oppId>
> </bidRequest>
> <bidRequest class_id="0" tracking_level="0" version="0">
> <oppId>44567889</oppId>
> </bidRequest>
> </boost_serialization>
>
> Any idea how to resolve this.
>
> Thanks,
> Sangeeta
>
> _______________________________________________
> Boost-users mailing list
> Boost-users@???
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
--
John Pretz -- P-23, MS H803
Los Alamos National Lab Los Alamos, NM 87545
Phone: (505)665-5847 Fax: (505)665-4121
#include <boost/serialization/nvp.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <iostream>
#include <sstream>
using namespace std;
using boost::serialization::make_nvp;
struct SerializeMe{
template <class Archive>
void serialize(Archive& ar){
ar & make_nvp("x",x);
ar & make_nvp("y",y);
}
double x;
double y;
};
using namespace std;
int main()
{
SerializeMe to_serialize;
to_serialize.x = 0;
to_serialize.y = 1;
ostringstream out;
{
boost::archive::xml_oarchive ar(out);
to_serialize.serialize(ar);
}
cout<<out.str()<<endl;
}
_______________________________________________
Boost-users mailing list
Boost-users@???
http://lists.boost.org/mailman/listinfo.cgi/boost-users