-
31 Jul 2012 1:05 AM #1
Unanswered: XMLStore
Unanswered: XMLStore
I have the XML of this format
Code:<?xml version="1.0" encoding="UTF-8"?> <users> <meta> <name>Spencer</name> </meta> <user> <id>1</id> <name>Ed Spencer</name> <email>ed@sencha.com</email> </user> <user> <id>2</id> <name>Abe Elias</name> <email>abe@sencha.com</email> </user> </users>
How to define the store/model to access <name> tag's value inside the <meta> tag ?
My store is,
Code:Ext.define('User', { extend: 'Ext.data.Model', fields: [{name:'id', mapping: 'user > id',type: 'string'}, {name:'name',mapping: '@name'} ] }); var store = Ext.create('Ext.data.Store', { autoLoad:true, model: 'User', proxy: { type: 'ajax', url : 'users.xml', reader: { type: 'xml', record: 'users', root: 'users' } } });
Am I correct in this way ?.
-
31 Jul 2012 5:35 AM #2Sencha - Community Support Team
- Join Date
- May 2012
- Location
- Istanbul
- Posts
- 1,331
- Vote Rating
- 77
- Answers
- 124
Use associations config of model class
Use associations config of model class
Hi
Try this model For nested xml -
Read API docs http://docs.sencha.com/ext-js/4-1/#!...g-associationsCode:Ext.define('app.model.Name', { extend: 'Ext.data.Model', fields: [{ name: 'name', mapping: 'name', type: 'string'}] }); Ext.define('app.model.User', { extend: 'Ext.data.Model', fields: [{ name: 'id', mapping: 'id', type: 'int'}, { name: 'name', mapping: 'name', type: 'string'}, { name: 'email', mapping: 'email', type: 'string'}], associations: [{ type: 'hasMany', model: 'app.model.Name', name: 'name', associationKey: 'User', reader: { type: 'xml', record: 'meta', root: 'meta' }} ], proxy: { type: 'ajax', url: 'data/example.xml', reader: { type: 'xml', record: 'User', root: 'Users' } } });
sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.
-
5 Aug 2012 10:26 PM #3
Will try it out this way and reply soon.


Reply With Quote