我对 RapidXML 很陌生。我想构建一个 Xml 文档并将其打印到文件中。一切正常,但我不确定我是否正确执行了该过程的一部分:
将属性添加到双精度节点。
我正在使用标准 C++ 的东西:
double value = 1.0;
std::ostringstream strs;
strs << value ;
std::string str = strs.str();
char* numBuff = doc.allocate_string(str.c_str());
xml_attribute<> *attr = doc.allocate_attribute("name",numBuff);
nodeRef->append_attribute(attr);
有没有更优雅/更快的方式?像(一厢情愿的想法):
double value = 1.0;
char* numBuff = doc.allocate_string_from_value(value);
xml_attribute<> *attr = doc.allocate_attribute("name",numBuff);
我需要将大量的双打保存到我的 xml 文件中,所以性能是我关心的主要问题。
问候,奥利弗