parse xml response with jQuery

前端 未结 4 623
旧巷少年郎
旧巷少年郎 2020-12-01 02:29

HI all,
I use jQuery to parse my xml responses.

I have this xml :


         


        
4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-01 02:53

    just to complement, i you use $.get:

    $.get($('file.xml').val(),{  } , doSomethingWithData); 
    

    function doSomethingWithData(data) {

     $(data).find("marker").each(function() {
    
    
            var marker = $(this);
    
    
         alert(marker.attr("lat"));
    
     });
    

    here tpicall used request.responseXML is the data in this case, and you have to encapsulate it in $(data) in order to work (this make me break the head about 3 hours ;S)

                         //    alert(markerh);
    
                    }
    

提交回复
热议问题