PDA

View Full Version : Load XML data from field into Ext.data.store?



jfizer
22 May 2009, 10:50 AM
No doubt this is a simple question and I'm just over tired, but how do I load XML stored in a textarea field on the page into an Ext.data.Store?
Works fine with the URL parameter, but I want to be able to make edits and then load a data grid.

jfizer
22 May 2009, 3:45 PM
Well, may not be the best method but the following works to generate an object "xmlDoc" which can then be passed to the Ext.data.Store as its Data property.

myData = String(document.getElementById('myXML').value);
//alert(myData);
if (window.ActiveXObject) {
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.loadXML(myData);
} else {
var xmlDoc = new DOMParser().parseFromString(myData,"text/xml");
}