且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用 jQuery 进行带有命名空间的 XML 解析

更新时间:2023-10-01 23:01:28

我知道了.

事实证明它需要 \ 来转义冒号.

Turns out that it requires \ to escape the colon.

$.get(xmlPath, {}, function(xml) {
    $("rs\:data", xml).find("z\:row").each(function(i) {
        alert("found zrow");
    });
}, "xml");

正如里奇指出的那样:

更好的解决方案不需要转义并且适用于所有现代"浏览器:

The better solution does not require escaping and works on all "modern" browsers:

.find("[nodeName=z:row]")