我需要编写两个xpath查询,其中一个选择特定元素的所有父元素,从该元素的直接父元素到根,并且我将能够选择元素的某些特定属性。
另一个查询选择元素的所有子元素,无论它们在哪里。
例如,如果xml文档如下:
<role key='total-admin'>
<role key='security-admin'>
<role key='users-admin'>
<role key='add-user'></role>
<role key='delete-user'></role>
<role key='deactivate-user'></role>
</role>
</role>
</role>
I want to select all parents of the element with key 'add-user' .the result would be:
[ 'users-admin' , 'security-admin' , 'total-admin' ]
I want to select all children of 'security-admin'. the result would be:
[ 'users-admin' , 'add-user' , 'delete-user' , 'deactivate-user' ]