How to use jQuery for XML parsing with namespaces

后端 未结 20 1797
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 10:17

I\'m new to jQuery and would like to parse an XML document.

I\'m able to parse regular XML with the default namespaces but with XML such as:



        
20条回答
  •  天命终不由人
    2020-11-22 10:24

    I got it.

    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");
    

    As Rich pointed out:

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

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

提交回复
热议问题