Ticket #4457 (closed bug: invalid)
text() with XML parsing is not working correctly in IE6/7
| Reported by: | rlejsza | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4 |
| Component: | core | Version: | 1.3.2 |
| Keywords: | text text() xml ie6 ie7 | Cc: | |
| Blocking: | Blocked by: |
Description
When text() function is called for string without html(xml) tags in it, in IE6/7 is returning wrong value.
Not affected: IE8 (also with IE7 compatibility mode), FF3, Opera 9.
How to reproduce:
var data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><string xmlns=\" http://192.168.2.3:81/WebService.asmx\">TEXT</string> ";
var ret = $(data).text();
alert(ret);
How to correct:
var data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><string xmlns=\" http://192.168.2.3:81/WebService.asmx\"><a>TEXT</a></string> ";
var ret = $(data).text();
alert(ret);
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

You cannot pass xml to the $(html) constructor. See the documentation:
http://docs.jquery.com/Core/jQuery#htmlownerDocument