View Full Version : One XML multiple Model

4 Nov 2011, 7:25 PM
I understand the example on the http://docs.sencha.com/touch/1-1/#!/api/Ext.data.XmlReader, well I think, but what if I need to load one XML that contains a lot of data and a list of elements like that for example :

<?xml version="1.0" encoding="UTF-8"?>
<name>Ed Spencer</name>
<name>Abe Elias</name>

In this example, I would need an Model containing all the parameters, and another with all the users, just like the example does.

I don't want to load the XML once per model, but once for all.
Any idea?

5 Nov 2011, 6:02 AM
Two ways I see to do this...

Do an Ext.Ajax.request and then create the two Stores by passing in the XML.

Have one Store load and when it loads, load that raw data from the Reader and pass it into the other Store.

5 Nov 2011, 8:04 PM
I can't figure out hout this works. Sorry, but I'm a beginner. Here is my code, close to the example, except, that my XML file is in a folder app and named myxml.xml. Also, I add a root params which represent the parent node of my user list.

I tried to display something, but may be I don't understand listeners enought. Here is my code

Ext.regModel('User', {
fields: ['id', 'name', 'email']

var store = new Ext.data.Store({
model: 'User',
listeners: {
'load' : function(store,records,options) {
proxy: {
type: 'ajax',
url : 'app/myxml.xml',
root : 'users',
reader: {
type: 'xml',
record: 'user'

Can you help me on that. I just want to start by loading an XML file. Note, that I on my local folder, not on a server. At the end, it will be an Mobile App that will load that XML.

8 Nov 2011, 1:04 PM
I did the load with Ajax, thanks that works.
Actually I donc pass the XML element to the Store, but I create the Model by setting parameter from their own XML node value.

But for problem with Chrome, loading a XML from a server when this is in an APP, I need to change to JSONP.