Hello,

I manipulate XML with jQuery with no problem in all browseres but not in Internet Explorer. I serched bug-fix and I found "metadata.js" but still not working in my Internet Explorer 7 :sad: .

Does anyone now a fix for this problem? It's just too nice to manipulate XML with jQuery...


As a matter of fact... a simple example of extracting some data:
Script page:

<!DOCTYPE html PUBLIC "-//W3C//  DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
 <html>
   <head>
     <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
     <title>Address book</title>
	 <script src="jquery.js" type="text/javascript"></script>
	 <script src="metadata.js" type="text/javascript"></script>
	 	
     <script type="application/javascript">
	 $(function() {
         $('#update-target a').click(function() {
             $.ajax({
                 type: "GET",
                 url: "labels.xml",
                 dataType: "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>

labels.xml file:

<?xml version="1.0" encoding="iso-8859-1"?>
 <labels>
   <label id='ep' added="2003-06-10">
     <name>Ezra Pound</name>
     <address>
       <street>45 Usura Place</street>
       <city>Hailey</city>
       <province>ID</province>
     </address>
   </label>
   <label id='tse' added="2003-06-20">
     <name>Thomas Eliot</name>
     <address>
       <street>3 Prufrock Lane</street>
       <city>Stamford</city>
       <province>CT</province>
     </address>
   </label>
   <label id="lh" added="2004-11-01">
     <name>Langston Hughes</name>
     <address>
       <street>10 Bridge Tunnel</street>
       <city>Harlem</city>
       <province>NY</province>
     </address>
   </label>
   <label id="co" added="2004-11-15">
     <name>Christopher Okigbo</name>
     <address>
       <street>7 Heaven's Gate</street>
       <city>Idoto</city>
       <province>Anambra</province>
     </address>
   </label>
 </labels>

Code works perfectly in all browsers except IE (Internet Explorer - "failing forever". Good job MS :D )

Greetings!
I am having the exact problem you describe here right now, even after so much time since you posted it. Did you ever get an answer to this problem?

Thanks!
-Sigo

Hello,

I manipulate XML with jQuery with no problem in all browseres but not in Internet Explorer. I serched bug-fix and I found "metadata.js" but still not working in my Internet Explorer 7 :sad: .

Does anyone now a fix for this problem? It's just too nice to manipulate XML with jQuery...


As a matter of fact... a simple example of extracting some data:
Script page:

<!DOCTYPE html PUBLIC "-//W3C//  DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
 <html>
   <head>
     <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
     <title>Address book</title>
	 <script src="jquery.js" type="text/javascript"></script>
	 <script src="metadata.js" type="text/javascript"></script>
	 	
     <script type="application/javascript">
	 $(function() {
         $('#update-target a').click(function() {
             $.ajax({
                 type: "GET",
                 url: "labels.xml",
                 dataType: "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>

labels.xml file:

<?xml version="1.0" encoding="iso-8859-1"?>
 <labels>
   <label id='ep' added="2003-06-10">
     <name>Ezra Pound</name>
     <address>
       <street>45 Usura Place</street>
       <city>Hailey</city>
       <province>ID</province>
     </address>
   </label>
   <label id='tse' added="2003-06-20">
     <name>Thomas Eliot</name>
     <address>
       <street>3 Prufrock Lane</street>
       <city>Stamford</city>
       <province>CT</province>
     </address>
   </label>
   <label id="lh" added="2004-11-01">
     <name>Langston Hughes</name>
     <address>
       <street>10 Bridge Tunnel</street>
       <city>Harlem</city>
       <province>NY</province>
     </address>
   </label>
   <label id="co" added="2004-11-15">
     <name>Christopher Okigbo</name>
     <address>
       <street>7 Heaven's Gate</street>
       <city>Idoto</city>
       <province>Anambra</province>
     </address>
   </label>
 </labels>

Code works perfectly in all browsers except IE (Internet Explorer - "failing forever". Good job MS :D )

I think its bcos of
$(div_id).html(response_html) problem in IE.
If you try
document.getElementById(div_id).innerHTML = response_html;

Would work.

I found if I wrapped it in a div, it started working:

$("<div>" + xml + "</div>").each()

Less than ideal, but gets it done.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.