Tushar Chutani
Tushar Chutani

Reputation: 1570

XPath Help - Code for getting data before "<br>" Tag

So here is what I want to do to start off here is a simple sample HTML code

<html>
<body>
  <b>This a test <br>ABCD</b>
</body>
</html>

So now how can I get only the text "This a test" I tried to do something like this "/html/body/b" but I get "ABCD" as the output? What can I do to get "This is a test"?

Upvotes: 1

Views: 365

Answers (1)

Knowledge Craving
Knowledge Craving

Reputation: 7993

The XPath expression could be:-

/html/body/b[1]

This may provide you the string "This a test".

Hope it helps.

Upvotes: 1

Related Questions