Bug Tracker

Opened 15 years ago

Closed 15 years ago

Last modified 11 years ago

#3143 closed bug (wontfix)

XML parsing-related bug in IE

Reported by: jterran Owned by:
Priority: major Milestone: 1.3
Component: core Version: 1.2.6
Keywords: Cc:
Blocked by: Blocking:

Description

The each loop is never entered in IE6/IE7, but works just fine in Firefox 2:

function testXml()
{
	var theXml = "<test><item id='1'>one</item><item id='2'>two</item></test>";		
	
	$(theXml).find('item').each(function() 
	{
		var theItem = $(this);
		var theId = theItem.attr("id");
		var theText = theItem.text();		
		alert("Id=" + theId + " Text=" + theText);
	});
}

However, if I introduce a conditional XML DOM parse, the above example works just fine:

function testXml()
{
	var theXml = "<test><item id='1'>one</item><item id='2'>two</item></test>";		
	theXml = parseXml(theXml);
	
	$(theXml).find('item').each(function() 
	{
		var theItem = $(this);
		var theId = theItem.attr("id");
		var theText = theItem.text();		
		alert("Id=" + theId + " Text=" + theText);
	});
}

function parseXml(xml)
{	
	if (jQuery.browser.msie)
	{
		var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 
		xmlDoc.loadXML(xml);
		xml = xmlDoc;
	}
	
	return xml;
}

Version Info:

/*

  • jQuery 1.2.6 - New Wave Javascript *
  • Copyright (c) 2008 John Resig (jquery.com)
  • Dual licensed under the MIT (MIT-LICENSE.txt)
  • and GPL (GPL-LICENSE.txt) licenses. *
  • $Date: 2008-05-24 14:22:17 -0400 (Sat, 24 May 2008) $
  • $Rev: 5685 $ */

Attachments (2)

index.htm (268 bytes) - added by jterran 15 years ago.
HTML
foo.js (611 bytes) - added by jterran 15 years ago.
JS - Uncomment one line for IE workaround

Download all attachments as: .zip

Change History (8)

Changed 15 years ago by jterran

Attachment: index.htm added

HTML

Changed 15 years ago by jterran

Attachment: foo.js added

JS - Uncomment one line for IE workaround

comment:1 Changed 15 years ago by jterran

Anyone?

comment:2 Changed 15 years ago by flesler

Resolution: wontfix
Status: newclosed

Check this link : http://docs.jquery.com/Core/jQuery#html The jQuery constructor only supports html, not xml. The string is flushed into a div, that probably why IE blows up. Because the string isn't valid html.

comment:3 Changed 15 years ago by kenman

I can't believe this isn't supported.

comment:5 Changed 13 years ago by kenorb

wontfix means the patch does work, or not? Why this can't be fixed?

comment:6 Changed 11 years ago by chandu017@…

you made my Day, it worked, thnx!...........:)

comment:7 in reply to:  6 Changed 11 years ago by jterran

Replying to chandu017@…:

you made my Day, it worked, thnx!...........:)

Wow! Four years later. Pretty cool. You're welcome :)

Note: See TracTickets for help on using tickets.