jquery append() method on empty XML element
- by Anthony
This could just be a syntax error, but I'm trying to create a Document object from scratch, starting with document.implementation.createDocument() and then using jquery's append() method to add the elements. But it's not appending:
var myDoc = document.implementation.createDocument("", 'stuff', null);
$("stuff",myDoc).attr("test","tested");
$("stuff",myDoc).append("<test>A</test>");
$("<test>B</test>").appendTo("stuff",soapEnv);
var s = new XMLSerializer();
alert(s.serializeToString(soapEnv));
This should output:
<stuff test="tested">
<test>A</test>
<test>B</test>
</stuff>
But instead it outputs:
<stuff test="tested" />
So the selector seems to be working, just not the method. My only guess is the method doesn't account for the fact that elements are empty (<stuff />) until they have children. But that's just a guess.