Bug Tracker

Modify

Ticket #3143 (closed bug: wontfix)

Opened 5 years ago

Last modified 7 months ago

XML parsing-related bug in IE

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

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

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

Change History

Changed 5 years ago by jterran

HTML

Changed 5 years ago by jterran

JS - Uncomment one line for IE workaround

comment:1 Changed 5 years ago by jterran

Anyone?

comment:2 Changed 5 years ago by flesler

  • Status changed from new to closed
  • Resolution set to wontfix

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 5 years ago by kenman

I can't believe this isn't supported.

comment:5 Changed 3 years ago by kenorb

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

comment:6 follow-up: ↓ 7 Changed 7 months ago by chandu017@…

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

comment:7 in reply to: ↑ 6 Changed 7 months ago by jterran

Replying to chandu017@…:

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

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.