如何使用JDom2计算xpath而不考虑空文本节点
对于xml段:如何使用JDom2计算xpath而不考虑空文本节点,dom,xpath,implementation,jdom-2,Dom,Xpath,Implementation,Jdom 2,对于xml段: <tr> <td> Price: </td> <td> <span> <b> $11.85 </b> </span> </td> </tr> 但是我只想找到[$11.85]。那么,在不考虑空文本节点的情况下,如何计算xpath呢?尝试使用此xpath获得11
<tr>
<td>
Price:
</td>
<td>
<span>
<b>
$11.85
</b>
</span>
</td>
</tr>
但是我只想找到
[$11.85]
。那么,在不考虑空文本节点的情况下,如何计算xpath呢?尝试使用此xpath获得11.85美元:
//text()[normalize-space(.)!=''][ancestor::td/preceding-sibling::td[1][normalize-space(.)='Price:']]
谢谢你的回答!但在我的实际情况中,我希望基于前面的同级文本节点“Price”获得文本$11.85。
//text()[normalize-space(.)!=''][ancestor::td/preceding-sibling::td[1][normalize-space(.)='Price:']]