#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: | |
Blocked by: | Blocking: |
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 (2)
Change History (8)
Changed 14 years ago by
Changed 14 years ago by
comment:1 follow-up: 2 Changed 14 years ago by
comment:2 follow-up: 3 Changed 14 years ago by
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 follow-up: 4 Changed 14 years ago by
it's because XML is case-sensitive. anyways it's a bug, because jQuery converts the string in append() to upper case.
comment:4 Changed 14 years ago by
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 Changed 14 years ago by
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 14 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
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.
i found a similar problem: when traversing the children, none of the newly added entries will be shown: