4

Is there some kind of CSS multiple selector (comma) in XPath, so I could find fetch, say, //img and //*[@background] elements in one query?

1
  • 1
    Tutorial Is this what you're looking for ? Commented Jul 25, 2011 at 14:05

4 Answers 4

11

There is an or operator (|) in XPath:

//img|//*[@background]
Sign up to request clarification or add additional context in comments.

2 Comments

Oh, that was easy. Thanks! :)
unlike css comma it'd select either one correct? css comma would select both if possible.
3

Use |, e.g.: //img | //*[@background]

Comments

3

In addition to the "union" operator | which exists in XPath 1.0 and 2.0 there is also the "comma" operator , in XPath 2.0 to form a sequence of items e.g. //img, //*[@background].

Comments

2

Yes, it is the pipe (|).

//img | //*[@background]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.