您的位置:首页 > 其它

pugixml学习笔记5 XPath

2014-02-02 13:39 471 查看
void XPath_test()
{
pugi::xml_document doc;
doc.load_file(L"skn.xml");
pugi::xpath_node_set xpathnode = doc.select_nodes("root/SafeDebug");

for (pugi::xpath_node_set::const_iterator it = xpathnode.begin(); it != xpathnode.end(); it++)
{
pugi::xpath_node node = *it;
printf("属性值 %s\n",node.node().attribute("age").value());
}

}


使用代码如上,xml文件如下

<?xml version="1.0"?>
<root>
<SafeDebug age="23" weight="65">Simple node</SafeDebug>
</root>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: