PDA

View Full Version : Create XML Document from XML String



sridhar.boganathan
14 Mar 2012, 10:40 PM
Hi All,

As per my requirement, I have to create XML Document from XML String. I could not find a way to create XML Document with Ext JS.

I could not use this piece of code directly with Ext JS to create XML Document.
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else // IE 5/6
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.loadXML('<xmlString>');
Please advice,
Sridhar

mitchellsimoens
15 Mar 2012, 6:36 AM
Are you trying to load XML? Or you need to create XML?

sridhar.boganathan
15 Mar 2012, 9:59 AM
I need to create XML from string.

droessner
15 Mar 2012, 11:51 AM
var xmlText = '<yourxml></yourxml>,
xmlDoc,
parser;


if (window.DOMParser) {
parser = new DOMParser();
xmlDoc = parser.parseFromString(xmlText,'text/xml');
} else {
xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
xmlDoc.async = 'false';
xmlDoc.loadXML(xmlText);
}