If you have the xml below in $(xml), you would get droopy using:
$(xml).find("animal").find("dog").find("beagle").text()
Is there an equivalent way in jQuery to use xpath like
$(xml).xpathfind("/animal/dog/beagle").text()?
<animal>
<dog>
<beagle>
droopy
</beagle>
...
jQuery supports basic XPath actually, so you can just use find
.
Alternatively, use CSS selector syntax.
For your particular example, you would use $(xml).find( "animal > dog > beagle" ).text()
jQuery used to support very basic XPath, including the example you gave.
$(xml).find("animal/dog/beagle")
EDIT: You're right, they've apparently removed it from the core, so you have to use a "compatibility" plugin.
EDIT: Updated link to xpath plugin XPath Plugin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With