【发布时间】:2015-04-21 14:04:14
【问题描述】:
我找到了一些关于如何使用 boost 属性树来读取 xml 文件的绝妙示例。然而,对我来说真正令人头疼的是提取 DOCTYPE 值。给定一个带有以下行的 xml 文件:
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
如果我这样做:
// Create an empty property tree object
boost::property_tree::ptree pt;
// Load the XML file into the property tree.
boost::property_tree::read_xml(filenameIn, pt);
// and then immediately write it back out again...
boost::property_tree::write_xml(filenameOut, pt);
我希望 content(filenameOut) == content(filenameIn)。
但事实并非如此。具体来说,缺少 DOCTYPE 节点。因此如何提取 DOCTYPE 节点的值?
【问题讨论】: