当函数保存xml时,是否可以通过write_xml调用中用作第三个参数的xml_writer_settings来省略xml声明?我的意思是,我不希望有最初的“xml version =“blah” encoding =“blah blah”部分。我正在互联网上搜索,但仍然找不到答案。该怎么做?
最佳答案
不,不可能。 look here for members of xml_writer_settings
同样,write_xml
调用的write_xml_internal
是(在Boost 1.52中)
template<class Ptree>
void write_xml_internal(
std::basic_ostream<typename Ptree::key_type::value_type> &stream,
const Ptree &pt,
const std::string &filename,
const xml_writer_settings<typename Ptree::key_type::value_type> & settings)
{
typedef typename Ptree::key_type::value_type Ch;
typedef typename std::basic_string<Ch> Str;
stream << detail::widen<Ch>("<?xml version=\"1.0\" encoding=\"")
<< settings.encoding
<< detail::widen<Ch>("\"?>\n");
write_xml_element(stream, Str(), pt, -1, settings);
if (!stream)
BOOST_PROPERTY_TREE_THROW(xml_parser_error("write error", filename, 0));
}