Lisa Herzog
Lisa Herzog

Reputation: 35

Xpath Expression: Select Elements Using Values Embedded in Tags

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[@class=""] because the class tag is not unique. Also tried indexing but the results are not robust.

<dl class="object-kenmerken-list">
<dt> Vraagprijs</dt>
<dd class="xxx">
    <span class ="xxx"> 400.000</span>
    <span class ="xxx"> irrelevant data</span>
</dd>
</dl>

Upvotes: 0

Views: 43

Answers (1)

LMC
LMC

Reputation: 12662

This xpath should get the wanted value

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

Upvotes: 2

Related Questions