Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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
使用xpath从元素加载值_Xpath - Fatal编程技术网

使用xpath从元素加载值

使用xpath从元素加载值,xpath,Xpath,我对xpath有点陌生。所以我不知道怎么做。我有这个档案 <map> <object name="object (1)"> <position>564.014893 -7424.033691 35.448875</position> <rotation>0.000000 0.000000 0.000000</rotation> <model>3494

我对xpath有点陌生。所以我不知道怎么做。我有这个档案

<map>    
    <object name="object (1)">
        <position>564.014893 -7424.033691 35.448875</position>
        <rotation>0.000000 0.000000 0.000000</rotation>
        <model>3494</model>
    </object>
</map>

564.014893 -7424.033691 35.448875
0.000000 0.000000 0.000000
3494
正如你所看到的那样

564.014893-7424.033691 35.448875

564.014893是X

-7424.033691是Y

35.448875是Z


如何加载X(或Y/Z)?

如果您支持xpath 2,可以使用标记化在空格上拆分字符串。X、Y和Z值分别为:

tokenize(map/object/position, ' ')[1]
tokenize(map/object/position, ' ')[2]
tokenize(map/object/position, ' ')[3]
substring-before(map/object/position, " ")
substring-before(substring-after(map/object/position, " "), " ")
substring-after(substring-after(map/object/position, " "), " ")
如果您只支持XPath1,那么可以使用substring before和substring after方法。X、Y和Z值分别为:

tokenize(map/object/position, ' ')[1]
tokenize(map/object/position, ' ')[2]
tokenize(map/object/position, ' ')[3]
substring-before(map/object/position, " ")
substring-before(substring-after(map/object/position, " "), " ")
substring-after(substring-after(map/object/position, " "), " ")

它说,;无法识别的函数也许我可以用这些加载它们?两种解决方案都提供了无法识别的功能?您使用什么来评估XPath-即支持哪些函数?我认为您提供的链接不会有帮助,除非您只想获取整个文本节点,然后使用xpath以外的其他方法解析文本。