如何使用xpath2获取匹配谓词的属性

时间:2013-07-14 15:10:02

标签: xpath

我有一个像这样的xml: -

<include><method wrap="true"><name>methodA</name></method>...</include>

方法节点可以使用值为true或false的wrap属性。缺少属性应该意味着它是假的。

我的谓词是这样的: -

//include/method[matches(str, methodA)]

获取匹配的节点。 如何获取wrap属性并计算属性是否丢失?

1 个答案:

答案 0 :(得分:0)

试试这个:

//include/method[@wrap='true'][name = 'methodA'] 

如果存在属性换行且值为字符串true,则wrap属性的测试将仅为true

相关问题