Boost Ptree的XML版本和编码 [英] XML version and encoding from boost ptree
问题描述
我正在使用boost ptree来解析xml
I am using boost ptree to parse xml
read_xml(stream, pt, trim_whitespace | no_comments);
<?xml version="1.0" encoding="windows-1252"?>
<rss>
<channel>.....</channel>
</rss>
如何读取xml的版本和编码:
我尝试了以下
How to read the version and encoding of the xml : I tried the following
std::string encoding = pt.get<std::string>("<xmlattr>.encoding", "");
给出空字符串。
如何获取xml的版本和编码?
which gives empty string. How to get the version and encoding of xml?
推荐答案
处理指令不是XML元素(实际上是,这是...一条处理指令。)
The processing instruction is not an XML element (in fact, it's... a processing instruction).
处理指令在< xmlattr>
中没有属性感。您将注意到,没有与之对应的ptree节点。
Processing instructions do not have attributes in the <xmlattr>
sense. You will note that there is no ptree node corresponding to it.
这是实现您可能想要的目标的一种未记录的方法:添加xml-stylesheet处理指令以提升property_tree
Here's an undocumented way to achieve what you likely want: Add xml-stylesheet processing instructions to boost property_tree
这篇关于Boost Ptree的XML版本和编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!