开发者

How to parse a local xml file mentioned below in sencha touch mobile

As i am new to Sencha touch mobile stuck in parsing a normal xml file and pass it to a store object and populate in a panel view. Can any one help me out how to parse a XML file kept locally in the project(as mentioned below data.xml) or as a string. Below is the XML and thanks in advance.


data.XML:-

<dataSrc>
    <section>
        <elem>
                 <id>1677</id>
                 <name>
                 <![CDATA[  United Kingdom]]>
                </name>  
         </elem>

    </section>
     <section>
        <elem>
                 开发者_如何转开发<id>1678</id>
                 <name>
                 <![CDATA[  United Arab Emirates]]>
                </name>  
         </elem>

    </section>
        .......
</dataSrc>


Have a model with the xml properties and a store with a xml proxy.

Ext.regModel('elem', {
    fields: [
        {name: 'id', type: 'string'},
        {name: 'name',  type: 'string'}
    ]
});

var myStore = new Ext.data.Store({
    model: 'elem',
    proxy: {
        type: 'xml',
        url : '/data.xml',
        reader: {
            type: 'xml',
            root: 'dataSrc',
            record: 'elem'
        }
    },
    autoLoad: true
});

Then you have the contents of the xml parsed in the store. Read all about this at http://dev.sencha.com/deploy/touch/docs/?class=Ext.data.Store

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜