【问题标题】:How to store an XML file content into a std::string or CString, at compilation time?如何在编译时将 XML 文件内容存储到 std::string 或 CString?
【发布时间】:2010-06-07 12:03:26
【问题描述】:

XML 包含 C++ 可能误解的符号(如 http://www.w3.org/2000/10/XMLSchema 中的 //)

我想知道您是否知道在编译时将一些硬编码的 XML 包含到 std::string 或 CString 中的简洁方法。

(实际上,我正在尝试对 .xsd 文件进行编码以验证某些 xml 输入,因为我不想依赖此 xsd 文件的存在与否,因此我希望将其编译为二进制文件)

【问题讨论】:

  • “//”序列在 C++ 中并不特殊。

标签: c++ xml stdstring


【解决方案1】:
const char* XML_STRING = "<?xml version=\"1.0\"?><Test></Test>";

std::string aTestXmlStr(XML_STRING);

【讨论】:

  • 很多thanx,你完全正确,唯一的问题是使用双引号。这样就可以正常工作: static const string strXsd = "\ w3.org/2001/XMLSchema\" >\ \ \ \ \ \ \ \ \ \ \ \";
猜你喜欢
  • 2021-04-02
  • 1970-01-01
  • 2021-12-19
  • 1970-01-01
  • 2018-03-20
  • 2021-07-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多