I am a newbie to javascript but here is what I am trying to do. Note that I looked around for an answer but nothing helped.

I am trying to traverse XML elements but it is not working in IE8. It is working just fine in Firefox though. And by not working I mean it doesn't go inside the loop even though there are elements.

This is the XML I am trying to traverse:

var $anXml = $('<node id="anID" inline="0" leaf="true">'
+'<sub_node1>Text \(more text\)</sub_node1>'
+'<sub_node2>Text \(more text\)</sub_node2>'
+'</node>');

Here is the code I am using to traverse:

alert('children before loop: ' + $anXml.children.length);
$anXml.children().each(function() {
alert('child traversed!');
var $aChild = $(this);
$anotherXml.data(this.nodeName.toLowerCase(), $aChild.html());
});
alert('children after loop: ' + $anXml.children.length);

Here is the output of alerts:

children before loop: 2
children after loop: 2

The 'child traversed!' is never displayed.

Any thoughts would be much appreciated.