用Xpath刷选出节点为空的节点

来源:互联网 发布:广发白发大数据001731 编辑:程序博客网 时间:2024/06/05 03:17

Xpath刷选出节点

以下xml为例

<AccountBook> <Meals Total="2 /> <Clothes>hello</Clothes> <HouseRent></HouseRent></AccountBook>

选出属性为Total的节点的Xpath:

//AccountBook/Meals[@Total="2"]

选出Clothes节点值为hello的Xpath:

//AccountBook/Clothes[text()="hello"]

选出HouseRent节点值为空的Xpath:

//AccountBook/HouseRent[not(text())]

或者是:

//AccountBook/HouseRent[not(node())]

 

 

 

 

原创粉丝点击