jQuery won't parse xml with nodes called option

后端 未结 3 2007
既然无缘
既然无缘 2020-11-27 22:22

I\'m using jQuery to parse some XML, like so:

function enumOptions(xml) {
   $(xml).find(\"animal\").each(function(){  
       alert($(this).text());
   });
         


        
3条回答
  •  醉话见心
    2020-11-27 22:58

    On line 4448 of the unminified source for 1.4.2 is the culprit:

    // ( div = a div node )
    // ( elem = the xml you've passed to it )
    
    div.innerHTML = wrap[1] + elem + wrap[2]; 
    

    Consider this code:

    var d = document.createElement('div');
    d.innerHTML = "blah";
    
    alert(d.innerHTML); // barblah
    
    // tested on Firefox 3.6
    

    So, don't ask me why exactly, but it looks like something in the way the DOM handles it, not necessarily jQuery's fault.

    Perhaps just use a different node name?

提交回复
热议问题