PDA

View Full Version : read XML



myput
19 Oct 2011, 12:41 AM
Hello,
i'm trying to read an XML file, get the content and display this in a panel.
For that, i have chosen DataView ....
But nothing is displayed ....

I Call my DataView since a panel with:
items: [WPApp.views.WeatherPanelContainer],

DataView:


WPApp.views.WeatherPanelContainer = new Ext.DataView({
store: WPApp.stores.WeatherPanelContainerStore,
itemSelector: "div.item",
tpl: '{lsup}',
fullscreen: true
});


And the store and model:


Ext.regModel('WPApp.models.WeatherPanelContainerModel', {
fields: [
{name: 'lsup', type: 'string'},
{name: 'tmp', type: 'string'},
{name: 'flik', type: 'string'},
{name: 't', type: 'string'},
{name: 'icon', type: 'string'}
]
});


WPApp.stores.WeatherPanelContainerStore = new Ext.data.Store({
model: 'WPApp.models.WeatherPanelContainerModel',
proxy: {
type: 'ajax',
url: 'weather.xml',
reader: {
type: 'xml',
root: 'weather',
record: 'cc'
}
},
autoLoad: true
});


I don't understand what is itemSelector: "div.item". But i know i need it cause else, nothing work ....

Can you help me please?

ForAllThat
19 Oct 2011, 12:47 AM
Try changing tpl to itemTpl?.

myput
19 Oct 2011, 12:50 AM
thanks to answer.


I did that, but all the application don't work when i do itemTpl or if i put out itemSelector ...

myput
19 Oct 2011, 12:53 AM
And my XML is:


<weather ver="2.0">
<head>
<locale>en_US</locale>
<form>MEDIUM</form>
<ut>F</ut>
<ud>mi</ud>
<us>mph</us>
<up>in</up>
<ur>in</ur>
</head>
<loc id="FRXX5514">
<dnam>Vals-les-Bains, France</dnam>
<tm>9:47 AM</tm>
<lat>44.67</lat>
<lon>4.37</lon>
<sunr>8:02 AM</sunr>
<suns>6:52 PM</suns>
<zone>2</zone>
</loc>
<cc>
<lsup>10/19/11 9:30 AM Local Time</lsup>
<obst>Saint-Etienne, FRANCE</obst>
<tmp>48</tmp>
<flik>44</flik>
<t>Light Rain</t>
<icon>11</icon>
<bar>
<r>30.06</r>
<d>rising</d>
</bar>
<wind>
<s>9</s>
<gust>N/A</gust>
<d>310</d>
<t>NW</t>
</wind>
</cc>
</weather>

myput
19 Oct 2011, 12:57 AM
Omg, i needed to write in my view:


tpl: new Ext.XTemplate([
'<tpl for=".">',
'<div class="car">{lsup}</div>',
'</tpl>'
]),