I need to create an xml from javascript where some xml element tag would contain simple string data while some will contain html data. for that i have created a function
function element(child, childValue) {
var element = document.createElementNS(url, child);
var elementText = document.createTextNode(childValue);
element.appendChild(elementText);
return element;
}
By calling abobe function this way "function(widgetData, widget1)". it creates below xml element.
"<widgetData>widget1<widgetData>"
Now i need to create xml tag containing html data for that calling above function following way
function(widgetData, '<p>hello, world </p>')
it creates below xml element
<widgetData><p>Hello, world</p></widgetData>
I think we can do this by CDATA
<widgetData><![CDATA[<p>hello, world </p>]]></widgetData>
But don't know how to do it.
I tried
var elementText = document.CreateCDataSection(childValue);
but it is giving error "undefined function" in chrome .And in Firefox "Unsupported html document" error occurs.