我的XML有什么问题吗?

编程入门 行业动态 更新时间:2024-10-24 20:20:49
本文介绍了我的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有什么问题吗?

本文发布于:2023-10-22 23:04:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1518996.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有什么   XML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!