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,我在“title”元素中编写xpath,希望在同一父元素(特性)中获得以下“abbrev”。我正在使用XPath1.0 <root> <feature> <title>Burst Cycle Length</title> <titlealts class="- topic/titlealts "> <navtitle>Burst Cycle Length</navtitle>

我在“title”元素中编写xpath,希望在同一父元素(特性)中获得以下“abbrev”。我正在使用XPath1.0

<root>
<feature>
    <title>Burst Cycle Length</title>
    <titlealts class="- topic/titlealts ">
        <navtitle>Burst Cycle Length</navtitle>
    </titlealts>
    <abbrv>BCL</abbrv>
    <featbody/>
</feature>
<feature>
    <title>Burst Parameter</title>
    <titlealts class="- topic/titlealts ">
        <navtitle>Burst Cycle Length</navtitle>
    </titlealts>
    <abbrv>BCP</abbrv>
    <featbody/>
</feature>
</root>

突发周期长度
突发周期长度
BCL
突发参数
突发周期长度
BCP

如果要获取所有节点:

/root/feature/title/following-sibling::abbrv
或者,如果您想要一个特定的:

/root/feature/title[.='Burst Cycle Length']/following-sibling::abbrv
这与前面的输出相同:

/root/feature[1]/title/following-sibling::abbrv
如果要获取与当前“title”节点具有相同父节点的第一个“abbrv”节点

这将得到一个“abbrv”的列表


您到底想通过XPath搜索什么?我不明白你的问题
following-sibling::node()[name() ='abbrv'][1]
following-sibling::node()[name() ='abbrv']