我的XML有什么问题吗? [英] Something wrong with my XML?

查看:201
本文介绍了我的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:'invest'
}
},
listeners :{
single:true,
datachanged:function(){
Ext.getBody()。unmask();
var items = [];
store。每个(function(rec){
alert(rec.get('investor'));

});

,我的xml文件是:

 <?xml version = 1.0encoding =UTF-8?> 
< root>
<投资者>
<投资者>活动< / investor>
<投资者& ; / investor>
< investor>保守< / investor>
<投资者>日交易者< / investor>
< investor> Active< / investor>
< / investors>
< events>
< event> 3个月到期< / event>
< event> LEAPS< / event>
< event> Monthlies< / event>
< event>每月到期< / event>
< event> Weeklies< / event>
< / events>
< price>
< price> $ 0.5< / price>
< price> $ 0.05< / price>
< price> $ 1< / price>
< price> $ 22< / price>
< price> $ 100.34< / price>
< / prices>
< / root>

wen我只运行代码活动出来。 。 。 。



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



请帮忙 。 。 。 。

解决方案

每个事情都很好,我的xml格式应该是这样的:






活动
3个月到期
$ 0.5


进取
LEAPS
$ 0.05


保守
月份
$ 1


日交易者
每月到期
$ 22


非常活跃
Weeklies
$ 100.34

 <?xml version =1.0encoding =UTF-8?> 
< main>
< root>
< investor> Active< / investor>
< event> 3个月到期< / event>
< price> $ 0.5< / price>
< / root>
< root>
< investor> Aggressive< / investor>
< event> LEAPS< / event>
< price> $ 0.05< / price>
< / root>
< root>
< investor>保守< / investor>
< event> Monthlies< / event>
< price> $ 1< / price>
< / root>
< root>
< investor> Day Trader< / investor>
< event>每月到期< / event>
< price> $ 22< / price>
< / root>
< root>
< investor>非常活跃< / investor>
< event> Weeklies< / event>
< price> $ 100.34< / price>
< / root>
< / main>


i'm parsing an xml with my extjs but it returns only one of the five components.

only the first one of the five components.

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

            });

and my xml file is:

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

wen i run the code only "Active" comes out. . . .

i know that i'm doing something wrong but i'm not sure what....

please help . . . . .

解决方案

Every thing was fine execpt that my xml format should be like this:

Active 3 Month Expiry $0.5 Aggressive LEAPS $0.05 Conservative Monthlies $1 Day Trader Monthly Expiries $22 Very Active Weeklies $100.34

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

这篇关于我的XML有什么问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆