Index: boost/archive/basic_archive.hpp =================================================================== --- boost/archive/basic_archive.hpp (revision 82766) +++ boost/archive/basic_archive.hpp (working copy) @@ -236,7 +236,8 @@ no_codecvt = 2, // suppress alteration of codecvt facet no_xml_tag_checking = 4, // suppress checking of xml tags no_tracking = 8, // suppress ALL tracking - flags_last = 8 + skip_unknown_tail_tags = 16, // skip unknown tags in input file before closing tag which aren't listed in serialize() method + flags_last = 16 }; BOOST_ARCHIVE_DECL(const char *) Index: boost/archive/basic_text_iprimitive.hpp =================================================================== --- boost/archive/basic_text_iprimitive.hpp (revision 82766) +++ boost/archive/basic_text_iprimitive.hpp (working copy) @@ -75,6 +75,8 @@ io::ios_flags_saver flags_saver; io::ios_precision_saver precision_saver; + typedef BOOST_DEDUCED_TYPENAME IStream::char_type StreamCharType; + #ifndef BOOST_NO_STD_LOCALE boost::scoped_ptr archive_locale; basic_streambuf_locale_saver< Index: boost/archive/impl/basic_xml_iarchive.ipp =================================================================== --- boost/archive/impl/basic_xml_iarchive.ipp (revision 82766) +++ boost/archive/impl/basic_xml_iarchive.ipp (working copy) @@ -48,9 +48,37 @@ return; bool result = this->This()->gimpl->parse_end_tag(this->This()->get_is()); if(true != result){ + if( 0 == (this->get_flags() & skip_unknown_tail_tags) ){ boost::serialization::throw_exception( archive_exception(archive_exception::input_stream_error) ); + } + + //We haven't read closing tag, therefore we've read opening one and + //we should skip all tags, include nested, up to original closing tag + + //Current nesting level (how many closing tags we have to skip). + //When it becomes 0 we'll find closing tag with name `name`, + unsigned int skipDepth = 2; + + //Contents of element is not used + std::basic_string data; + + //We've just found opening tag and we have to skip its contents + this->This()->gimpl->parse_string( this->This()->get_is(), data ); + + for(;;){ + //Is this opening tag? + if( this->This()->gimpl->parse_end_tag(this->This()->get_is()) ){ + if( 0 == --skipDepth ) + break; + } + else{ + //No, we've found opening one. Let's skip the content + ++skipDepth; + this->This()->gimpl->parse_string( this->This()->get_is(), data ); + } + } } // don't check start tag at highest level