How to use jQuery for XML parsing with namespaces

后端 未结 20 1776
隐瞒了意图╮
隐瞒了意图╮ 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:44

    None of the solutions above work that well. I found this and has been improved for speed. just add this, worked like a charm:

    $.fn.filterNode = function(name) {
        return this.find('*').filter(function() {
           return this.nodeName === name;
        });
    };
    

    usage:

    var ineedthatelementwiththepsuedo = $('someparentelement').filterNode('dc:creator');
    

    source: http://www.steveworkman.com/html5-2/javascript/2011/improving-javascript-xml-node-finding-performance-by-2000/

提交回复
热议问题