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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:14:24+00:00 2026-05-13T18:14:24+00:00

I’m starting to use boost::serialization on XML archives. I can produce and read data,

  • 0

I’m starting to use boost::serialization on XML archives. I can produce and read data, but when I hand-modify the XML and interchange two tags, it “fails to fail” (i.e. it proceeds happily).

Here’s a small, self-complete example showing what I see:

#include <iostream>
#include <fstream>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/split_member.hpp>
using namespace std;

int main (void)
{
  boost::archive::xml_oarchive oa (cout);
  static const string producer = "XXX", version  = "0.0.1";
  oa << boost::serialization::make_nvp ("producer", producer);
  oa << boost::serialization::make_nvp ("producer_version", version);
}

This writes XML to standard output, which contains:

<producer>XXX</producer>
<producer_version>0.0.1</producer_version>

Now, I replace all the code in the main function with a reader:

  boost::archive::xml_iarchive ia (cin);
  string producer, version;
  ia >> boost::serialization::make_nvp ("producer", producer);
  ia >> boost::serialization::make_nvp ("producer_version", version);
  cout << producer << "  " << version << endl;

which works as expected when fed the previous output (outputs “XXX 0.0.1”). If, however, I feed it XML in which I changed the order of the two lines “producer” and “producer_version”, it still runs and outputs “0.0.1 XXX”.

Thus, it fails to recognize that the tags don’t have the expected names, and just proceed. I would have expected it to thrown a xml_archive_parsing_error exception, as indicated in the doc.

Does someone here have experience with that? What I am doing wrong?

  • 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-13T18:14:24+00:00Added an answer on May 13, 2026 at 6:14 pm

    Just changing the order of the two lines won’t cause an xml_archive_parsing_error exception. The doc you’ve linked says that itself:

    (…)This might be possible if only the data is changed and not the XML attributes and nesting structure is left unaltered.(…)

    You haven’t changed attributes and the order change has kept the structure (still two fields on the first level of your XML). No exception will ever be thrown this way.

    Also, when reading a XML using the make_nvp function, the name parameter won’t put any restriction on what is being read. It will just tell arbitrarily the name to be used with the new name-value pair.

    So, you can change the name of your XML tags on your input, as long you don’t change your expected order i.e. you could rename producer and producer_version on your XML to foo and bar and still would read the serialized data correctly i.e.:

    <foo>XXX</foo>
    <bar>0.0.1</bar>

    And your printed answer would still be “XXX 0.0.1”.

    Since this only formatting your serialized data as a XML, there is no interest in checking the tag names. They are only used for making your serialized output more readable.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.