PDA

View Full Version : Read XML data issue



sanjay_1985
3 Feb 2014, 10:11 PM
Hi All,
I am not able to read the below XML file. Store is not getting loaded. Could you please tell me what am I missing here?



<?xml version="1.0" encoding="UTF-8"?>


<access>
<MENUS menu.name="XXX">
<Permission name="XXXUpdate">
<component name="Save">savebuttonid</component>
<component name="add">addbuttonid</component>
<component name="accesscode">accesscode button id</component>
</Permission>


<Permission name="XXXRestore">
<name>XXXRestore</name>
<component name="restore">restorebuttonid</component>
</Permission>


<Permission name="XXXExpire">
<component name="expire">expirebuttonid</component>
</Permission>
</MENUS>


</access>








Ext.define('User', {
extend: 'Ext.data.Model',
proxy: {
type: 'ajax',
reader: 'xml'
},
fields:[
{ name: 'MENUS', type: 'string', mapping:'@menu.name'},
{ name: 'Permission', type: 'string', mapping:'Permission'} ,
{ name: 'component', type: 'string', mapping:'component'}


]
});
var store = new Ext.data.Store({
model: 'User',
autoLoad:true,
proxy: {
type: 'ajax',
url: 'Test.xml',
reader: {
type: 'xml',
root:'access',
record: 'MENUS'
},listeners:{
load:function(store, records, successful, eOpts)
{
alert("store loaded");

}
}
}
});

palakurthivishal
4 Feb 2014, 3:18 AM
Hello sanjay_1985,
Use an XmlStore to make things easier.
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.XmlStore