0

For an xml segment:

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

when I evaluate the xpath: //text()[preceding::text()[normalize-space(.)!=''][position()=1][normalize-space()='Price:']] , the result is :

[ 
]
[

]
[ 

]
[ 
$11.85
]

but I only want to find the [$11.85]. So what can I do to evaluate a xpath without considering the empty text node?

B_PRIEUR
  • 160
  • 1
  • 1
  • 18
radium
  • 11
  • 1

1 Answers1

0

Try this XPATH to get $11.85:

//text()[normalize-space(.)!=''][ancestor::td/preceding-sibling::td[1][normalize-space(.)='Price:']]
Navin Rawat
  • 3,208
  • 1
  • 19
  • 31
  • Thank you for your answer! But in my real situation, I want to get text $11.85 based on the preceding-sibling Text node "Price". – radium May 22 '13 at 07:27