我的XML文件是:是否可以從包含相似標籤的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>
<event>Weeklies Expiry</event>
</events>
<prices>
<price>0.05</price>
<price>0.5</price>
<price>1</price>
<price>1</price>
<price>22</price>
<price>100.34</price>
</prices>
</root>
我的ExtJS的代碼是:
Ext.regModel('Card', {
fields: ['investor','event','price']
});
var store = new Ext.data.Store({
model: 'Card',
proxy: {
type: 'ajax',
url: 'http:/.../initpicker.php',
reader: {
type: 'xml',
record: 'root'
}
},
listeners: {
single: true,
datachanged: function(){
var items = [];
store.each(function(r){
stocks.push({text: '<span style="color:Blue;font-weight:bolder;font-size:30px;">'+ r.get('price') +'</span>'});
values.push({text: '<span style="font-weight: bold;font-size:25px;">'+ r.get('investor') +'</span>'});
points.push({text: '<span style="font-weight: bold;font-size:25px;">'+ r.get('event') +'</span>'});
});
}
}
});
store.read();
我的問題是,如果我的XML包含像五次我們仍然可以分析數據相同的標籤。 。 。 。 。?
我試過這個代碼,但它只是解析第一個..........................
如果有任何其他方式請建議。 。 。
謝謝。
您可能應該已經更新了您的原始問題。 http://stackoverflow.com/questions/4645294/something-wrong-with-my-xml – Hemlock 2011-01-12 14:39:05
需要一些幫助,以解決以下問題。請幫助 http://stackoverflow.com/questions/10971255/read-nested-xml-to-model-with-hasmany-association-sencha-extjs – buddy 2012-06-10 18:46:52