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