我的xml有很多以下元素的外观:
<attribute>
<attributeCode>aaa</attributeCode>
<attributeName>bbb</attributeName>
<attributeType>ccc</attributeType>
<attributeValue>ddd</attributeValue>
</attribute>
我使用xpath表达式返回 &#39; //属性/的attributeName [的attributeName =&#34; BBB&#34;]&#39; 它工作正常,但我需要返回attributeValue所以我改为: &#39; //属性/的AttributeValue [的attributeName =&#34; BBB&#34;]&#39; 我希望能得到这样的信息。但它返回空值。有什么问题?
答案 0 :(得分:1)
由于您选择了attributeValue
,因此您需要先转到父元素,以检查attributeName
。
这将有效(注意:../
):
//attribute/attributeValue[../attributeName='bbb']