如何解析这种格式的xml数据?

时间:2011-01-18 06:49:28

标签: extjs sencha-touch xml-parsing

我试图解析这种格式的数据xml:

<?xml version="1.0" encoding="UTF-8"?> 
<root>
<list info="INFY, Jan 20 call, 40 cents or Lower" profit="60%" loss="gdh"/>
<list info="HPCL, Feb 20 PUT, 20 cents or Lower" profit="80%" loss="fgh"/>
<list info="AAPL, May 290 call, 90 cents or Lower" profit="ss" loss="20%"/>
<list info="DIA, April 105 call, 32 cents or Lower" profit="ghh" loss="20%"/>
<list info="GOOG, Aug 350 call, 47 cents or Lower" profit="100%" loss="sdgd"/>
</root>

使用此代码:

Ext.regmodel('picks',{fields: ['info','profit','loss']});
alert();
var pickstore = new Ext.data.store({
                                    model: 'picks',
                                    proxy: {
                                            type: 'ajax',
                                            url: 'http://1........ksxml.xml',   //url is fine it's good and working..
                                            reader: {
                                                     type: 'xml',
                                                     record: 'list'
                                                    }
                                            },
                                    listeners: {
                                                single: true,
                                                datachanged: function(){
                                                                        pickstore.each(function(pr){
                                                                                        alert(pr.get('@info'));
                                                                                       });
                                                                        }
                                                }       
                                   });

pickstore.read();

我不知道原因,但即使第一个警报()没有显示,我也无法解析。

请帮助.....

1 个答案:

答案 0 :(得分:0)

Ext.regModel( 'picks' ......

Capital M - Javascript区分大小写