Index: boost/property_tree/detail/xml_parser_write.hpp =================================================================== --- boost/property_tree/detail/xml_parser_write.hpp (revision 66409) +++ boost/property_tree/detail/xml_parser_write.hpp (working copy) @@ -88,6 +88,8 @@ } } } + + // Write element if (pt.data().empty() && pt.empty()) // Empty key @@ -116,8 +118,12 @@ if (optional attribs = pt.get_child_optional(xmlattr())) for (It it = attribs.get().begin(); it != attribs.get().end(); ++it) stream << Ch(' ') << it->first << Ch('=') << - Ch('"') << it->second.template get_value >() << Ch('"'); + Ch('"') << encode_char_entities( + it->second.template get_value >() + ) << Ch('"'); + + if ( has_attrs_only ) { // Write closing brace