Why is IE8 on XP not properly reading from XML using JQuery?

Posted by dking on Stack Overflow See other posts from Stack Overflow or by dking
Published on 2010-05-12T01:49:43Z Indexed on 2010/05/12 1:54 UTC
Read the original article Hit count: 215

Filed under:
|
|

Given this XML in data.xml

<?xml version="1.0" encoding="utf-8"?>
<data>
  <bar>100</bar>
</data>

I want to display the content from the "bar" element using the following code in test.html

<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
  $.get('data.xml', function(xml) {
    var foo = $(xml).find('bar').text();
    document.write("<span>foo: [" + foo + "]</span>");
  });
</script>
</body>
</html>

The output in webkit based browsers:

foo: [100]

The output in IE8 on XP:

foo: []

Why do webkit browsers read the element's content correctly while IE8 interprets it as an empty string?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about internet-explorer