Side navigation
#4531 closed bug (invalid)
Opened April 13, 2009 05:37PM UTC
Closed April 14, 2009 03:59PM UTC
Last modified March 15, 2012 02:36PM UTC
$("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 (6)
Changed April 13, 2009 05:54PM UTC by comment:1
Changed April 13, 2009 08:10PM UTC by comment:2
Replying to [comment:1 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
Changed April 13, 2009 08:35PM UTC by comment:3
it's because XML is case-sensitive.
anyways it's a bug, because jQuery converts the string in append() to upper case.
Changed April 14, 2009 12:17AM UTC by comment:4
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
Changed April 14, 2009 03:02PM UTC by comment:5
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:
Changed April 14, 2009 03:59PM UTC by comment:6
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:
function listEntries(target) {
$("data", d).children("entry").each(function() {
$("#entries").append("<p>"+$(this).attr("class")+"</p>");
});
}