我在"标题"中编写xpath; element想得到关注" abbrev"在同一个父(特征)内。我正在使用xpath 1.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>
答案 0 :(得分:0)
如果你想获得所有节点:
/root/feature/title/following-sibling::abbrv
或者,如果你想要一个特定的:
/root/feature/title[.='Burst Cycle Length']/following-sibling::abbrv
这与前面的输出相同:
/root/feature[1]/title/following-sibling::abbrv
答案 1 :(得分:0)
如果您想获得与当前“标题”节点具有相同父节点的第一个“abbrv”节点
following-sibling::node()[name() ='abbrv'][1]
这将获得“abbrv”
的列表following-sibling::node()[name() ='abbrv']