jquery解析XML及獲取XML節點名稱


jquery獲取XML節點名稱的幾種方法以:

  • 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);
            });
        }   
    });
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM