I'm trying to generate a XML from client side XML according to this link. But it isn't work. Here is my js code:
// XML Builder
$.createElement = function(name)
{
return $('<'+name+' />');
};
$.fn.appendNewElement = function(name)
{
this.each(function(i)
{
$(this).append('<'+name+' />');
});
return this;
}
generateXMLFromXML(1);
function generateXMLFromXML(id)
{
var $root = $('<?xml version="1.0" encoding="utf-8" ?>');
$root.append(
$('row').append (
$('page').text(1)
)
);
console.log($.isXMLDoc($root)); // return false
$root.find('page').each(function(){
console.log($(this).text());
});
}
I'm hoping jQuery can help me out. And any idea?