Given any xpath query, can we say that there exists some CSS selector that will match the same elements?
-
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..Mathijs Flietstra– Mathijs Flietstra2014-01-23 18:37:59 +00:00Commented Jan 23, 2014 at 18:37
-
@MathijsFlietstra I only search stackoverflow :/MxLDevs– MxLDevs2014-01-23 18:44:18 +00:00Commented Jan 23, 2014 at 18:44
-
@MxyL: Why do you limit yourself so?BoltClock– BoltClock2014-01-24 03:00:06 +00:00Commented Jan 24, 2014 at 3:00
-
@BoltClock I don't think it's limiting myself.MxLDevs– MxLDevs2014-01-24 16:49:18 +00:00Commented 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?Armen Michaeli– Armen Michaeli2018-01-26 15:00:15 +00:00Commented Jan 26, 2018 at 15:00
Add a comment
|
1 Answer
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.
2 Comments
BoltClock
"QED. Ipso facto. Lorum Ipsum." ಠ_ಠ