首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >配置Ext.data.XmlStore以从响应中获取自定义标签

配置Ext.data.XmlStore以从响应中获取自定义标签
EN

Stack Overflow用户
提问于 2010-11-13 12:05:33
回答 1查看 3.3K关注 0票数 0

您好,我有以下从服务器返回的xml :代码:

link text

我似乎不能得到正确的xml存储配置。特别是,我希望能够获得自定义标签:名称,内部和引用,这是返回的结果集的属性。谢谢!

EN

回答 1

Stack Overflow用户

发布于 2010-11-14 08:39:20

尝试此代码(将test.xml替换为您的XML源)

代码语言:javascript
复制
    // create the Data Store
var store = new Ext.data.Store({
    // load using HTTP
    url: 'test.xml',
    // the return will be XML, so lets set up a reader
    reader: new Ext.data.XmlReader({
           // records will have an "customer" tag
           record: 'customer',
       }, ['id','field1', 'field2', 'field3'])
});

// create the grid
var grid = new Ext.grid.GridPanel({
    store: store,
    columns: [
        {header: "id", width: 120, dataIndex: 'id', sortable: true},
        {header: "field1", width: 180, dataIndex: 'field1', sortable: true},
        {header: "field2", width: 115, dataIndex: 'field2', sortable: true},
        {header: "field3", width: 100, dataIndex: 'field3', sortable: true}
    ],
    renderTo:'example-grid',
    width:540,
    height:200
});
store.load();

代码语言:javascript
复制
Ext.Ajax.request({
       url: 'test.xml',
       success: function(response){
        console.debug(response);
        if (Ext.DomQuery.selectNode("/rootNode/name", response.responseXML)) {
            var name = Ext.DomQuery.selectValue("/rootNode/name",  response.responseXML);
            console.debug(name);
        } 

       },
       failure: function () { console.log('failure');}
    });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4170900

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档