PDA

View Full Version : Parse XML data question



sanjay_1985
4 Feb 2014, 5:53 AM
Hi All,
I have given my XML and code read the XML below.
My requirement is, how do i print all 'components' if give "XXXUpdate" as input? Can someone help me with this?



<access>
<total>1</total>
<success>true</success>
<menus 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">
<component name="restore">restorebuttonid</component>
</Permission>


</menus>
</access>









Ext.define('User', {
extend: 'Ext.data.Model',
fields: ['Permission','component']
});


var store = Ext.create('Ext.data.Store', {
model: 'User',
autoLoad:true,
proxy: {
type: 'ajax',
url : 'Test2.xml',
reader: {
type : 'xml',
model: 'User',
record: 'menus',
root: 'access'
}
}, listeners:{
load:function(store, recs, successful, eOpts) {

//print records here
}

}
});

slemmon
6 Feb 2014, 12:50 PM
With irregular data structures you will often want to use a function in your field mapping (there is a request internally to get functions as values for mapping added to the API docs).

You can do something like:

3dk

slemmon
6 Feb 2014, 1:10 PM
Or, if all you needed was the components and not really the permission info you might do something like:

3dm