2 ms·
>and XPath == CSS-like selectors with a different set of characters. I also have a feeling, that jQuery reinvents XPath.
by nivertech 16y ago
>and XPath == CSS-like selectors with a different set of characters.
I also have a feeling, that jQuery reinvents XPath.
- Groxx 16y agoNot if you take jQuery and compare it to XML library X, because that's the actual comparison. XPath == Sizzle, not jQuery - jQuery adds functions to manipulate what the selector returned, which the selector really has no business doing.
- nivertech 16y agoWhat in jQuery is a chain of multiple selectors and filters, can be done using single query in XPath, i.e. "document()/html//div[class='title']//img[class='icon']/@src"
- Groxx 16y agoI gather you haven't done much jQuery coding. That's equivalent to: $("html div.title img.icon").attr("src") The last .attr("src") is purely because jQuery always deals with a node / a collection of nodes. You can also do arbitrary attribute searches: $("html div[class~='title'] img[src*='google']") // "~=" == "contains word" - space-delimited to match html classes // "*=" == "contains substring" http://api.jquery.com/category/selectors/ http://api.jquery.com/category/selectors/
- nailer 16y agoYou're right, but jquery doesn't handle XML namespaces. Alas I wish it did.