【问题标题】:Loading xml from memory with Xerces使用 Xerces 从内存中加载 xml
【发布时间】:2012-03-09 09:13:20
【问题描述】:

我得到了一些我想用 Xerces 解析的合理 xml 数据(由 CodeSynthesis 生成)。

在磁盘上它是加密的,所以我加载它,解密它然后......我被卡住了,因为 Xerces 只接受文件作为输入。

我曾考虑过重载“读取器”之一(即 std::istream 或 xercesc::InputSource)并伪造光盘读取,但它看起来既古怪又不雅。

有没有更简单、更整洁的方法来做到这一点?

谢谢!

【问题讨论】:

    标签: c++ xml file memory xerces


    【解决方案1】:

    您可以使用@987654321@ 类:

    MemBufInputSource* pMemBufIS = new MemBufInputSource((const XMLByte*)sXmlContent.c_str(), sXmlContent.length(), "SysID", false);
    m_saxParser.parse(*pMemBufIS);
    delete pMemBufIS;
    

    而不是

    m_saxParser.parse(sXmlFilePath.c_str());
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-14
      • 1970-01-01
      • 2018-09-15
      • 2011-09-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多