Create XML document on-fly with jQuery update document tree and get document XML as text

by ArtyomShegeda

JavaScript

(function(){
    try{
        var xml = $($.parseXML('<?xml version="1.0" encoding="utf-8" ?><root />'));
        $('root',xml).append($('<obj />', xml).text('some text').attr({someAttr:'100500'}));
        $(document.body).text((new XMLSerializer()).serializeToString(xml.context));
    }catch(e){
        document.write(e.message);
    }
})();