0

对于 xml 段:

<tr>
  <td>
   Price:
  </td>
  <td>
      <span>
         <b>
           $11.85
         </b>
      </span>
  </td>
</tr>

当我评估 xpath: //text()[preceding::text()[normalize-space(.)!=''][position()=1][normalize-space()='Price:']]时,结果是:

[ 
]
[

]
[ 

]
[ 
$11.85
]

但我只想找到[$11.85]. 那么在不考虑空文本节点的情况下,我能做些什么来评估 xpath?

4

1 回答 1

0

试试这个 XPATH 以获得 11.85 美元:

//text()[normalize-space(.)!=''][ancestor::td/preceding-sibling::td[1][normalize-space(.)='Price:']]
于 2013-05-22T05:16:05.840 回答