Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用JDom2计算xpath而不考虑空文本节点_Dom_Xpath_Implementation_Jdom 2 - Fatal编程技术网

如何使用JDom2计算xpath而不考虑空文本节点

如何使用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

对于xml段:

<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:']]