Extjs 我的XML有问题吗?

Extjs 我的XML有问题吗?,extjs,xml-parsing,Extjs,Xml Parsing,我正在用extjs解析xml,但它只返回五个组件中的一个 Ext.regModel('Card', { fields: ['investor'] }); var store = new Ext.data.Store({ model: 'Card', proxy: { type: 'ajax', url: 'xmlformat.xml', reader: { type: 'xml',

我正在用extjs解析xml,但它只返回五个组件中的一个

Ext.regModel('Card', {
    fields: ['investor']    
});

var store = new Ext.data.Store({
    model: 'Card',
    proxy: {
        type: 'ajax',
        url: 'xmlformat.xml',
        reader: {
            type: 'xml',
            record: 'investors'
        }
    },
    listeners: {
        single: true,
        datachanged: function(){
            Ext.getBody().unmask();
            var items = [];
            store.each(function(rec){
                                        alert(rec.get('investor'));

            });
只有五个组件中的第一个

Ext.regModel('Card', {
    fields: ['investor']    
});

var store = new Ext.data.Store({
    model: 'Card',
    proxy: {
        type: 'ajax',
        url: 'xmlformat.xml',
        reader: {
            type: 'xml',
            record: 'investors'
        }
    },
    listeners: {
        single: true,
        datachanged: function(){
            Ext.getBody().unmask();
            var items = [];
            store.each(function(rec){
                                        alert(rec.get('investor'));

            });
我的xml文件是:

<?xml version="1.0" encoding="UTF-8"?>
<root>
<investors>
    <investor>Active</investor>
    <investor>Aggressive</investor>
    <investor>Conservative</investor>
    <investor>Day Trader</investor>
    <investor>Very Active</investor>
</investors>    
<events>
    <event>3 Month Expiry</event>
    <event>LEAPS</event>
    <event>Monthlies</event>
    <event>Monthly Expiries</event>
    <event>Weeklies</event>
</events>
<prices>
    <price>$0.5</price>
    <price>$0.05</price>
    <price>$1</price>
    <price>$22</price>
    <price>$100.34</price>
</prices>   
</root>

忙碌的
侵略性的
保守的
日内交易者
非常活跃
3个月到期
跳跃
每月
每月到期日
周刊
$0.5
$0.05
$1
$22
$100.34
当我运行代码时,只有“活动”出现

我知道我做错了什么,但我不知道是什么


请帮忙

一切都很好,我的xml格式应该是这样的:

忙碌的 3个月到期 $0.5 侵略性的 跳跃 $0.05 保守的 每月 $1 日内交易者 每月到期日 $22 非常活跃 周刊 $100.34


忙碌的
3个月到期
$0.5
侵略性的
跳跃
$0.05
保守的
每月
$1
日内交易者
每月到期日
$22
非常活跃
周刊
$100.34

您需要访问sencha.com教程,了解如何在网格中使用XML。


您不应该考虑如何正确构造XML,以便数据存储可以使用它。

需要配置Ext XML网格,以查找要映射到存储/网格中每个记录的重复元素。您为
投资者
配置了它,其中只有1个。然后,您为
investor
映射了一个字段,它只是获取它在该“行”的“列”中遇到的第一个字段

网格中“行”的重复元素应该是
investor
,而不是
investors

更改:
记录:“投资者”
收件人:
记录:“投资者”