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

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.




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

Search: