Roman Bats
Roman Bats

Reputation: 1795

Xpath - Get HTML element if its class contains some text

Can I get an element if its class contains some text?

Example:

<div class="headerbody"></div>   - match (header)
<div class="headerbottom"></div>   - match (header)
<dov class="text"></div>     - not match (header)

Upvotes: 19

Views: 36142

Answers (1)

Pavel Veller
Pavel Veller

Reputation: 6105

you could use contains() in your XPath predicate. like this:

div[contains(@class, 'header')]

Upvotes: 52

Related Questions