如何在sencha touch mobile中解析下面提到的本地xml文件

发布于 2024-12-06 07:08:07 字数 871 浏览 0 评论 0原文

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

在巴黎塔顶看东京樱花 2024-12-13 07:08:07

拥有一个具有 xml 属性的模型和一个具有 xml 代理的商店。

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

然后您就可以在商店中解析 xml 的内容。请访问 http://dev.sencha.com 阅读所有相关内容/deploy/touch/docs/?class=Ext.data.Store

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文