我想使用 sencha touch 解析 xml,我已经尝试了 stckovrflow 中的所有可能性,但没有任何显示:
XML 数据:来自:http ://www.aufaitmaroc.com/feeds/maroc.xml
商店:
Ext.define("MyApp2.store.NewsStore", {
extend: "Ext.data.Store",
requires: ["Ext.data.proxy.JsonP", "Ext.dataview.List", "MyApp2.model.News" ,"Ext.data.reader.Xml"],
config: {
model: "MyApp2.model.News",
autoLoad: true,
proxy: {
type: 'jsonp',
url: 'http://www.aufaitmaroc.com/feeds/maroc.xml',
reader: {
type: 'xml',
record: 'item',
rootProperty: 'channel'
}
}
}
});
我的模型:
Ext.define("MyApp2.model.News", {
extend: "Ext.data.Model",
config: {
type:'tree',
fields: [
{name: 'title', type: 'auto'}
]
}
});
我的观点 :
{
xtype: "list",
store: "NewsStore",
itemTpl: '<h1>{title}</h1>'
}
我在 chrome 的控制台中有这个错误:
我试图解决我的问题:我在我的 apache 的 HTTPD.conf 中添加了这个(我正在使用 WampServer)
AddType application/x-font-woff .woff
AddType application/rss+xml .xml
我创建了:httpd-proxy.conf 并将其放在额外的文件夹中
我的 httpd-proxy.conf
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /EMBackend http://localhost:8383/MyApp2/index.html
ProxyPassReverse /EMBackend http://localhost:8383/MyApp2/index.html
<Location /EMBackend>
Order allow,deny
Allow from all
</Location>
我已将此添加到 httpd.conf:
Include conf/extra/httpd-proxy.conf
& 仍然无法显示任何数据。任何帮助将不胜感激:)
Ps:我尝试像这样使用JsonP:
proxy: {
type: 'jsonp',
url: 'https://ajax.googleapis.com/ajax/services/feed/load? v=1.0&q=http://www.aufaitmaroc.com/feeds/maroc.xml',
reader: {
type: 'json',
rootProperty: 'responseData.feed.entries'
}
}
我没有得到所有数据,你可以尝试将 url 放入浏览器。