jquery解析XML及獲取XML節(jié)點(diǎn)名稱的實(shí)現(xiàn)代碼

字號(hào):


    下面小編就為大家?guī)?lái)一篇jquery解析XML及獲取XML節(jié)點(diǎn)名稱的實(shí)現(xiàn)代碼。小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。
    jquery獲取XML節(jié)點(diǎn)名稱的幾種方法以:
    • get(0).tagName
    $(this).get(0).tagName
    • [0].tagName[0]
    $(this)[0].tagName
    • context.nodeName
    $(this).context.nodeName
    function getXMLData(){
      $.ajax({  
        url:'data.xml',  
        type: 'GET',  
        dataType: 'xml',  
        timeout: 1000,  
        error: function(xml){  
          alert('Error loading XML document'+xml);  
        },  
        success: function(xml){  
          $("data",xml).children().each(function(){
            alert($(this).context.nodeName);
          });
        }  
      }); 
    }
    以上這篇jquery解析XML及獲取XML節(jié)點(diǎn)名稱的實(shí)現(xiàn)代碼就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考