Home > Enterprise >  Xpath Expression: Select Elements Using Values Embedded in Tags
Xpath Expression: Select Elements Using Values Embedded in Tags

Time:09-09

I am trying to retrieve the data point "400.000" using the data point ("Vraagprijs") of the preceding "dt" tag. What I have in mind is "select the first dd/span element following the dt element which includes "Vraagprijs" (For reference see the code snippet below).

Note: I am not able to select my data point using //dd[@] because the class tag is not unique. Also tried indexing but the results are not robust.

<dl >
<dt> Vraagprijs</dt>
<dd >
    <span class ="xxx"> 400.000</span>
    <span class ="xxx"> irrelevant data</span>
</dd>
</dl>

CodePudding user response:

This xpath should get the wanted value

//dt[.="Vraagprijs"]/following-sibling::dd[1]/span[1]/text()
  • Related