ruby on rails - Select unique set of nodes with XPath? -
i want select set of elements nodes (the content of div[@class="adres"]):
<div class="kolumnastyl"> <div class="nazwa">abcd</div> <div class="adres"> 12-345 warszawa <br/> ul. krasnobrodzka 5 <br/> mazowieckie this can done with:
//div[@class="kolumnastyl"]/div[@class="adres"]/node() as happens, there 2 identical div[@class="adres"] on page, means node() selects content of both of them. can't, however, call //div[@class="kolumnastyl"][1] - doesn't select first occurrence.
how can select unique set of nodes if parent directory exists multiple times?
take @ "xpath first element of subset".
basically, predicates have higher precedence / , // operators.
so, (//div[@class="kolumnastyl"]//(div[@class="adres"]))[1] should return desired result.
also check out the spec more background info.
Comments
Post a Comment