View Full Version : Get XML stored in a variable into an object format

28 Feb 2013, 8:10 AM
I have XML that essentially looks like this. I would like to place it into an object so that it is more organized. I realize that the data store is expecting a file path for the URL parameter. Is there a way to just pass the data store a variable instead? I tried the code below but it looks for my XML like it is a file path instead of transforming it to an object.

global.EDRO = "<EDRO><RO><state>22</state><code>1</code></RO><RO><state>40</state><CODE>1</CODE></RO></EDRO>"
CMA.E_DISCOUNT_ROLLOUTS = new Ext.data.Store({
url: global.EDRO,
reader: new Ext.data.XmlReader({
record: 'ro',
fields: ['state', 'code']

28 Feb 2013, 8:31 AM
I found this code on google, it seems to work for me.

var doc = new DOMParser().parseFromString(xmlstr, "text/xml");}var memstore = new Ext.data.Store({ autoLoad: true, model: 'Person', data : doc, proxy: { type: 'memory', reader: { type: 'xml', record: 'Person' } }});