0

Given any xpath query, can we say that there exists some CSS selector that will match the same elements?

5
  • The answer is no, have a look here for an article by John Resig on some of the differences between the two. I do believe the opposite is the case: "All CSS selectors have an equivalent xpath query". But I found all this info on Google with a few keystrokes.. Commented Jan 23, 2014 at 18:37
  • @MathijsFlietstra I only search stackoverflow :/ Commented Jan 23, 2014 at 18:44
  • @MxyL: Why do you limit yourself so? Commented Jan 24, 2014 at 3:00
  • @BoltClock I don't think it's limiting myself. Commented Jan 24, 2014 at 16:49
  • Why is this question down-voted, when there are thousands upon thousands of ridiculously up-voted questions on SO that are arguably bad according to the guidelines, questions like stackoverflow.com/questions/1711/…, for example? Commented Jan 26, 2018 at 15:00

1 Answer 1

1

As pointed out in the comments, the answer is an emphatic no.

The simplest way is proof through contradiction, and that is a simple parent selector - ./../. Since the parent of an arbitrary node in an XML document can be retrieved by XPath, but no parent selector exists in CSS, is trivial to say that not every XPath has an equivilent CSS selector.

QED. Ipso facto. Lorum Ipsum.

Sign up to request clarification or add additional context in comments.

2 Comments

"QED. Ipso facto. Lorum Ipsum." ಠ_ಠ
@BoltClock Everything sounds better when accompanying by latin. Proofs are things. Ergo, Proofs sound better with latin. QED. Tempest Fugit. Veritaserum.

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.