程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> JSP編程 >> 關於JSP >> jquery解析xml

jquery解析xml

編輯:關於JSP

 

$.ajax({

                     url:url,

                     type:"POST",

                     //data:params,

                     dataType: "xml",

                     async: false,

                     success:function(data){

                           

                            //alert(userid);

                            $(data).find("Root").each(function(i){

                                   var length=$(this).children("PhoneBookCard").length;       //所有對象的長度象

 

                                   for(var i=0;i<length;i++){

                                         

                                          var cardId=$($(this).children("PhoneBookCard").get(i)).find("cardId").text();        //每一個對象下面的節點對

                                          alert(cardId)

                                   }

                                  

                                  

                            });

//上面兼容所有浏覽器

 

 

 

if(null!=data){

                                  

                                   var root=data.selectNodes("Root");

                                  

                                   for(var i=0;i<root.length;i++){

                                         

                                  

                                          var childNodes=root[i].childNodes;

                                          var childNodesLen=childNodes.length;

                                         

                                          for(var j=0;j<childNodesLen;j++){

                                          var cardId=$(childNodes[j]).find("cardId").text();      //id

                            //得到value值

              }

       }

}

//這個只兼容IE

});

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved