drhema
drhema

Reputation: 103

How to find xpath expression to select this text

I have this html code , trying many times to get the pure xpath for text "sample text" then "author" text in separate xpath and i don't find any criteria for that!!!

<div class="Text">
      “sample article here with quotation marks .”   
<br/>
  ―     
<a href="/author/link/xxxxx/">Author</a>

so please help , it make me mad!! thanks

Upvotes: 0

Views: 95

Answers (1)

alecxe
alecxe

Reputation: 474141

The first part you can get by getting the div by class, get br inside and retrieve the preceding-sibling's text:

//div[@class="Text"]/br/preceding-sibling::text()

The second part is easier, just get the text of a tag inside the div:

//div[@class="Text"]/a/text()

Upvotes: 2

Related Questions