how can i convert xpath like
/html/body/div[3]/ul/li[1]/a[5]
html > body > div[3] > ul > li[1] > a[5]
i believe, index is not supported with CSS3 selectors….so how to deal with this ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you find that Sizzle/jQuery can’t apply your CSS3 selector it might be better to use the XPath plugin which was part of the original release of jQuery (and then removed since few people actually used it).
XPath implementations in browsers tends to be much faster than the CSS engines. Also having JS parse & convert an XPath expression into CSS3 then having jQuery munge that into something the browser can implement (generally CSS2.1 selectors with a bit of JS assistance) is going to be much slower than executing the XPath directly in the browser.
Not only that, but there are things that XPath can do that CSS can’t. For example:
//h3[class="blog-title"]/../../div[class="blog-entry"]//input[fn:floor(value) > 3]which isn’t overly complex for XPath to execute, but impossible for CSS alone – moving back up the DOM and executing a function as part of the expression can’t (to my knowledge) be done yet, even in CSS3.