1

Given the example

<div class = "one">
<p>This is some text<p>
<p>This is some other text<p>
<div>
<div class = "two"> 
<p>This is some text<p>
<p>This is some other text<p>
<div>

extracting from class 'one' would be :

//div[contains(@class, 'one')]

How do I add the other class 'two', to the same XPath?

kjhughes
  • 106,133
  • 27
  • 181
  • 240

1 Answers1

1

This XPath,

//div[@class="one" or @class="two"]

will select all div elements with @class attribute values of "one" or "two".

For a more robust matching of @class that takes into account that @class attribute values can be space-separate lists, see this approach.

kjhughes
  • 106,133
  • 27
  • 181
  • 240