gpt4 book ai didi

c++ - 来自 boost ptree 的 XML 版本和编码

转载 作者:行者123 更新时间:2023-11-30 05:27:37 25 4
gpt4 key购买 nike

我正在使用 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的版本和编码?

最佳答案

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

处理指令在 <xmlattr> 中没有属性感觉。你会注意到没有对应的ptree节点。

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

关于c++ - 来自 boost ptree 的 XML 版本和编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37188774/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com