如何使用 RapidXML 获取 <node /> 中的所有字符串
how to use rapidxml get all string inside <node />
如果我有如下的xml内容
<node>
<content> hello <b>world</b>
<image src="src/image.jpg"/>
</content>
</node>
我想获得字符串形式的值,其中包含所有数据或者说
string all_data = node->get_XXXX????();
最后,all_data=="<content>hello<b>world</b>\n<image src=\"src/image.jpg \"/>\n</content>"
您需要使用rapidxml_print.hpp
中的函数print
请参见此处。http://rapidxml.sourceforge.net/manual.html#namespacerapidxml_1printing
// Print to string using output iterator
std::string s;
print(std::back_inserter(s), node, 0);
请注意,这可能会重新格式化标记周围的空白等。如果这对你来说很关键,你应该找到一种不同的方式来编码你的文档。