Link to home
Create AccountLog in
Avatar of JayKing81
JayKing81

asked on

How do I process XML using JQuery in Internet Explorer?

I am experiencing a problem processing a simple xml document using jquery in internet explorer. The idea is to parse selected elements off of the xml document and then append to the DOM. I have it working correctly in Firefox 2, but Internet Explorer 6 SP 2 is raining on my parade. Please see code snippet below for guidance. Thanks in advance.
html and javascript
=========================
<!DOCTYPE html PUBLIC "-//W3C//  DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
 <html>
   <head>
     <meta content="text/xml; charset=iso-8859-1" http-equiv="Content-Type">
     <title>Address book</title>
     <script src="jquery.js" type="text/javascript"></script>
     <script type="application/javascript">
     $(function() {
         $('#update-target a').click(function() {
             $.ajax({
                 type: "GET",
                 url: "label.xml",
                 dataType: "text/xml",
                 success: function(xml) {
                     $(xml).find('label').each(function(){
                         var id_text = $(this).attr('id')
                         var name_text = $(this).find('name').text()
 
                         $('<li></li>')
                             .html(name_text + ' (' + id_text + ')')
                             .appendTo('#update-target ol');
                     }); //close each(
                 }
             }); //close $.ajax(
         }); //close click(
     }); //close $(
     </script>
   </head>
   <body>
     <p>
       <div id='update-target'>
         <a href="#">Click here to load addresses</a>
         <ol></ol>
       </div>
     </p>
   </body>
 </html>
=========================================
xml file
 
<labels>
<label id="mj">
<name>Michael Jordan</name>
</label>
<label id="kb">
<name>Kobe Bryant</name>
</label>
</labels>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of JayKing81
JayKing81

ASKER

I actually figured this out a little while back, but you hit on the head. IE didn't like the application/javascript tag. Thanks.