<segmentFlightRef>
<referencingDetail>
<refQualifier>S</refQualifier>
<refNumber>4</refNumber>
</referencingDetail>
<referencingDetail>
<refQualifier>S</refQualifier>
<refNumber>1</refNumber>
</referencingDetail>
</segmentFlightRef>
<segmentFlightRef>
<referencingDetail>
<refQualifier>S</refQualifier>
<refNumber>5</refNumber>
</referencingDetail>
<referencingDetail>
<refQualifier>S</refQualifier>
<refNumber>1</refNumber>
</referencingDetail>
</segmentFlightRef>
<segmentFlightRef>
<referencingDetail>
<refQualifier>S</refQualifier>
<refNumber>1</refNumber>
</referencingDetail>
<referencingDetail>
<refQualifier>S</refQualifier>
<refNumber>5</refNumber>
</referencingDetail>
</segmentFlightRef>
在上面的xml中我想要“segmentFlightRef”标签,其子节点“refNumber”的值为“5”和“1”。必须考虑和序列,所以我只需要一个节点的子节点值为5和1的节点 请帮我 提前致谢
答案 0 :(得分:1)
XPath :
//segmentFlightRef[./referencingDetail[./refNumber[text()="5"] and ./following-sibling::referencingDetail[./refNumber[text()="1"]]]]
解释:
//segmentFlightRef[./referencingDetail[...]]
选择具有子元素<segmentFlightRef>
的{{1}}元素,条件如下:
标准我:
<referencingDetail>
让子元素./refNumber[text()="5"]
的内部文字等于<refNumber>
。
标准II :
"5"
并且具有条件的下一个/同级节点and ./following-sibling::referencingDetail[./refNumber[text()="1"]]
:具有内部文本等于<referencingDetail>
的子元素<refNumber>
。
答案 1 :(得分:0)
的XPath:
//segmentFlightRef[referencingDetail[following-sibling::referencingDetail/refNumber = 1]/refNumber = 5]