kortovos
24 Sep 2010, 12:03 AM
How do you insert data, from an xml string into a store.
var xmlstring = '<?xml version="1.0" encoding="UTF-8"?><orderlist><order><orderid>2005048</orderid></order><order><orderid>3000359</orderid></order></orderlist>';
// convert the string to an XML object
var xmlobject = (new DOMParser()).parseFromString(xmlstring, "text/xml");
// get the XML root item
var root = xmlobject.getElementsByTagName('orderlist')[0];
var orderStore = new Ext.data.XmlStore({
model: 'order',
proxy: {
type:'ajax',
storeId: 'data',
record: 'order'
},
autoload: true,
autosave: true
});
//doesn't work
orderStore.loadData(xmlobject);
//also doesn't work
for (var iNode = 0; iNode < root.childNodes.length; iNode++) {
var node = root.childNodes.item(iNode);
orderStore.add(node);
}
I have been at this for more a long time, anyone got any idea what I am doing wrong? Any help would be highly appreciated.
var xmlstring = '<?xml version="1.0" encoding="UTF-8"?><orderlist><order><orderid>2005048</orderid></order><order><orderid>3000359</orderid></order></orderlist>';
// convert the string to an XML object
var xmlobject = (new DOMParser()).parseFromString(xmlstring, "text/xml");
// get the XML root item
var root = xmlobject.getElementsByTagName('orderlist')[0];
var orderStore = new Ext.data.XmlStore({
model: 'order',
proxy: {
type:'ajax',
storeId: 'data',
record: 'order'
},
autoload: true,
autosave: true
});
//doesn't work
orderStore.loadData(xmlobject);
//also doesn't work
for (var iNode = 0; iNode < root.childNodes.length; iNode++) {
var node = root.childNodes.item(iNode);
orderStore.add(node);
}
I have been at this for more a long time, anyone got any idea what I am doing wrong? Any help would be highly appreciated.