Results 1 to 3 of 3

Thread: Parse XML data question

  1. #1
    Ext JS Premium Member
    Join Date
    Apr 2009
    Posts
    117

    Default Answered: Parse XML data question

    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?

    Code:
    <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>

    Code:
    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
        	    	}
        	    	
        	    }
        	});

  2. Or, if all you needed was the components and not really the permission info you might do something like:


  3. #2
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165
    Answers
    505

    Default

    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:


  4. #3
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165
    Answers
    505

    Default

    Or, if all you needed was the components and not really the permission info you might do something like:


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •