jQuery-xpath找到吗? [英] jQuery - xpath find?

查看:84
本文介绍了jQuery-xpath找到吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果$(xml)中包含以下xml,则使用以下命令会出现下垂:

If you have the xml below in $(xml), you would get droopy using:

$(xml).find("animal").find("dog").find("beagle").text()

jQuery是否有等效的方式使用

Is there an equivalent way in jQuery to use xpath like

$(xml).xpathfind("/animal/dog/beagle").text()?

<animal>
    <dog>
        <beagle>
            droopy
        </beagle>
        ...

推荐答案

jQuery曾经支持非常基本的XPath,包括您提供的示例.

jQuery used to support very basic XPath, including the example you gave.

$(xml).find("animal/dog/beagle")

您是对的,他们显然已经从核心删除了它,因此您必须使用兼容性"

You're right, they've apparently removed it from the core, so you have to use a "compatibility" plugin.

更新了xpath插件的链接 XPath插件

Updated link to xpath plugin XPath Plugin

这篇关于jQuery-xpath找到吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆