Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Not 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.


What 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"


I 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/


You're right, but jquery doesn't handle XML namespaces. Alas I wish it did.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: