Ticket #4531 (closed bug: invalid)
$("root", xmlData).append("<node />"); doesn't append anything
| Reported by: | fishbone | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4 |
| Component: | unfiled | Version: | 1.3.2 |
| Keywords: | xml;modification | Cc: | |
| Blocking: | Blocked by: |
Description
if d is xmlData loaded with $.ajax,
doesn't work: $("data", d).append("<entry class='c' />");
works: $("data", d).append($("<entry class='d' />"));
tested with the available jQuery nightly downloaded 2009/04/13
Attachments
Change History
comment:1 follow-up: ↓ 2 Changed 4 years ago by fishbone
i found a similar problem: when traversing the children, none of the newly added entries will be shown:
function listEntries(target) {
$("data", d).children("entry").each(function() {
$("#entries").append("<p>"+$(this).attr("class")+"</p>");
});
}
comment:2 in reply to: ↑ 1 ; follow-up: ↓ 3 Changed 4 years ago by fishbone
Replying to fishbone:
i found a similar problem: when traversing the children, none of the newly added entries will be shown:
function listEntries(target) {
$("data", d).children("entry").each(function() {
$("#entries").append("<p>"+$(this).attr("class")+"</p>");
});
}
i noticed that .children() is case-sensitive traversing xml data. if you use .children("ENTRY") instead of .children("entry") it works. nevertheless i think it's a bug
comment:3 in reply to: ↑ 2 ; follow-up: ↓ 4 Changed 4 years ago by fishbone
it's because XML is case-sensitive. anyways it's a bug, because jQuery converts the string in append() to upper case.
comment:4 in reply to: ↑ 3 Changed 4 years ago by fishbone
sorry for bothering :) it isn't jQuery's bug. I tried it with element.appendChild(), and my lower case node name is converted into upper case
comment:5 in reply to: ↑ description Changed 4 years ago by fishbone
jQuery uses a div element for initializing the DOM nodes of the respective selector. the data is appended in line 2275:
div.innerHTML = wrap[1] + elem + wrap[2];
the innerHTML property does the upper case conversion. This is "recommended" for html but invalid for xml data. a discussion about this "innerHTML" behaviour can be found here: http://www.developer-x.com/content/innerhtml/
comment:6 Changed 4 years ago by dmethvin
- Status changed from new to closed
- Resolution set to invalid
All of jQuery's internal parsing treats the string as HTML, *not* XML; I've included links to the doc below. If you want to append unparsed XML content to an XML tree, parse it with an XML parser and pass the nodes to append() et al.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

