Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何使用boostptree读取xml格式的值密钥对_C++_Xml_Boost_Ptree - Fatal编程技术网

C++ 如何使用boostptree读取xml格式的值密钥对

C++ 如何使用boostptree读取xml格式的值密钥对,c++,xml,boost,ptree,C++,Xml,Boost,Ptree,我有以下xml文件的结构 <?xml version="1.0" encoding="UTF-8"?> <section name="pvf"> <section name="p1"> <item value="92.31335795746914" key="x"/> <item value="-746.7962776760924" key="y"/> <item value

我有以下xml文件的结构

<?xml version="1.0" encoding="UTF-8"?>
<section name="pvf">
    <section name="p1">
        <item value="92.31335795746914" key="x"/>
        <item value="-746.7962776760924" key="y"/>
        <item value="400.1902893301479" key="z"/>
        <item value="1" key="u1"/>
        <item value="7" key="type"/>
        <item value="Inlet 2" key="value"/>
    </section>
</section>

if (item.get<std::string>("<xmlattr>.key") == "x") {
    point[0] = item.get<float>"<xmlattr>.value");
}

就像在

中一样,您可以
项.get(“.value”)
而不是调用
stod
真点。有没有办法用
key=“x”
直接访问该值?看起来不像。路径语法非常简单
if (item.get<std::string>("<xmlattr>.key") == "x") {
    point[0] = item.get<float>"<xmlattr>.value");
}
m_level = pt.get("p1.x", 0);