jquery append() method on empty XML element

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);



var s = new XMLSerializer();

This should output:

<stuff test="tested">

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.


You can't construct a non-HTML node using jquery. This means $('<test>X</test>') isn't going to work, but $('<span>X</span>') will. (You can use jQuery to read an XML document, and look for things like $('test'), but constructing them is another matter.) This is due to how jQuery creates these elements internally.


Here is the documentation supporting my claim: http://api.jquery.com/jQuery/#jQuery2

A string of HTML to create on the fly. Note that this parses HTML, not XML.

Need Your Help

Display what is wrong with email address using jquery

javascript php jquery email

I have an html form that requests any email. currently, I have a php function that looks at the entry and confirms whether or not it is a valid government or military email. (This does not cover all

Java: GC tuning in master for master-slaves set up?

java garbage-collection

How should I tune GC (e.g. the type of collector, min/max size of heap, size of new/old gen, ratio of Eden to survivor etc.) for the following scenario? (I'm using Sun JDK 6, and available memory i...