【问题标题】:XML version and encoding from boost ptree来自 boost ptree 的 XML 版本和编码
【发布时间】:2016-09-08 09:32:35
【问题描述】:

我正在使用 boost ptree 来解析 xml

read_xml(stream, pt, trim_whitespace | no_comments);



<?xml version="1.0" encoding="windows-1252"?>
<rss>  
<channel>.....</channel> 
</rss>

如何读取 xml 的版本和编码: 我尝试了以下

std::string encoding =  pt.get<std::string>("<xmlattr>.encoding", "");

给出空字符串。 如何获取xml的版本和编码?

【问题讨论】:

    标签: c++ boost boost-propertytree


    【解决方案1】:

    处理指令不是 XML 元素(实际上,它是……处理指令)。

    处理指令没有&lt;xmlattr&gt; 意义上的属性。你会注意到没有与之对应的ptree节点。

    这是实现您可能想要的未记录的方法:Add xml-stylesheet processing instructions to boost property_tree

    【讨论】:

    • 谢谢@sehe,但我认为 xml_writer_setting 总是返回 utf-8 作为编码boost xml witer,不是吗?
    • 基本上,您会发现 Boost 没有 XML 库。
    猜你喜欢
    • 2019-11-09
    • 1970-01-01
    • 1970-01-01
    • 2020-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-03
    • 1970-01-01
    相关资源
    最近更新 更多