Given any xpath query, can we say that there exists some CSS selector that will match the same elements?
Asked
Active
Viewed 84 times
0
-
The answer is no, have [a look here for an article by John Resig on some of the differences between the two](http://ejohn.org/blog/xpath-css-selectors/). 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.. – Mathijs Flietstra Jan 23 '14 at 18:37
-
@MathijsFlietstra I only search stackoverflow :/ – MxLDevs Jan 23 '14 at 18:44
-
@MxyL: Why do you limit yourself so? – BoltClock Jan 24 '14 at 03:00
-
@BoltClock I don't think it's limiting myself. – MxLDevs Jan 24 '14 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 https://stackoverflow.com/questions/1711/what-is-the-single-most-influential-book-every-programmer-should-read, for example? – Armen Michaeli Jan 26 '18 at 15:00
1 Answers
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.
-
3
-
@BoltClock Everything sounds better when accompanying by latin. Proofs are things. Ergo, Proofs sound better with latin. QED. Tempest Fugit. Veritaserum. – Jan 24 '14 at 02:59