PDA

View Full Version : Help with XML Grid



nicosk
14 Jul 2010, 4:23 AM
Hi all, i am stuck and i need help on my problem.

I want to display some data on a grid that are taken from a remote XML file.



<Sport code="SOC" hid="4374355" id="1" name="SOCCER">
<Matchday date="2010-07-14">
<Match ct="0" id="681847" lastPeriod="2 HF" leagueCode="18066" leagueSort="10" leagueType="LEAGUE" startTime="00:00" status="Fin" statustype="fin" type="2" visible="1">
<Home id="3459" name="CORITIBA" standing="7"/>
<Away id="29105" name="BRAGANTINO" standing="15"/>
<Results>
<Result id="1" name="CURRENT" value="0-0"/>
<Result id="2" name="FT" value="0-0"/>
<Result id="3" name="HT" value="0-0"/>
<Period id="1" name="1HF">
<Detail name="SCORE" value="0-0"/>
</Period>
<Period id="2" name="2HF">
<Detail name="SCORE" value="0-0"/>
</Period>
<Period id="3" name="ET">
<Detail name="SCORE" value="0-0"/>
</Period>
<Period id="4" name="PEN">
<Detail name="SCORE" value="0-0"/>
</Period>
</Results>
<Information>
<season id="151">2009/2010</season>
<country id="19973">BRAZIL</country>
<parentCompetition id="25724">DIVISION 2</parentCompetition>
<league id="18066">DIVISION 2</league>
<shortName>D2</shortName>
<round>8</round>
<note/>
<bitArray/>
<timestamp/>
</Information>
</Match>

<Match ct="2" id="681862" lastPeriod="2 HF" leagueCode="18066" leagueSort="10" leagueType="LEAGUE" startTime="00:00" status="Fin" statustype="fin" type="2" visible="1">
<Home id="32007" name="ICASA" standing="8"/>
<Away id="10382" name="PARANA" standing="3"/>
<Results>
<Result id="1" name="CURRENT" value="3-0"/>
<Result id="2" name="FT" value="3-0"/>
<Result id="3" name="HT" value="3-0"/>
<Period id="1" name="1HF">
<Detail name="SCORE" value="3-0"/>
</Period>
<Period id="2" name="2HF">
<Detail name="SCORE" value="0-0"/>
</Period>
<Period id="3" name="ET">
<Detail name="SCORE" value="0-0"/>
</Period>
<Period id="4" name="PEN">
<Detail name="SCORE" value="0-0"/>
</Period>
<Scorers>
<Scorer name="DODO" period="1" team="32007" time="32" type=""/>
<Scorer name="CARLINHOS" period="1" team="32007" time="38" type=""/>
<Scorer name="XUXA" period="1" team="32007" time="45" type=""/>
</Scorers>
</Results>
<Information>
<season id="151">2009/2010</season>
<country id="19973">BRAZIL</country>
<parentCompetition id="25724">DIVISION 2</parentCompetition>
<league id="18066">DIVISION 2</league>
<shortName>D2</shortName>
<round>8</round>
<note/>
<bitArray/>
<timestamp/>
</Information>
</Match>


My code so far is:

var liveScoreStore = new Ext.data.Store({
// load using HTTP
url: 'http://data2.xscores.com/exporter/?usr=myusername&pwd=mypassword',

// the return will be XML, so lets set up a reader
reader: new Ext.data.XmlReader(
{record: 'Match'},
[
{name: "id", mapping: "@id" },
{name: "home", mapping: "[email protected]"},
{name: "away", mapping: "[email protected]"}
]
)
});



But i get the error :
"NetworkError: 501 Not Implemented - http://data2.xscores.com/exporter/?usr=myusername&pwd=mypassword"

i want to display a grid with

match id | home team | away team |

Can anyone help me with WHAT and WHERE i am wrong?

Regards,
Nicos

Animal
14 Jul 2010, 4:37 AM
Well the WHERE is your server. Obviously.

As to the WHAT, nobody can know. The person in charge of the server must fix it.

nicosk
14 Jul 2010, 4:40 AM
Well if i copy the correct URL in the browser, i get the XML file correctly

beegeedee
14 Jul 2010, 4:44 AM
Is the file accessing the XML on the same domain as the XML itself?

nicosk
14 Jul 2010, 4:47 AM
not its on a different server.

Animal
14 Jul 2010, 4:49 AM
The problem is on the server. It's sending back 501 Not Implemented.

Nothing to do with ExtJS at all.

Animal
14 Jul 2010, 4:50 AM
What HTTP methods are you allowed to use?

Did you check that you are using the correct HTTP method?

nicosk
14 Jul 2010, 6:25 AM
Hmmm, i don't really know which HTTP method i am allowed to use.. Where can i assign one method so that i could try?

Animal
14 Jul 2010, 6:29 AM
Look in Firebug...

You mean to say that you are using HTTP services with no way of looking at the traffic?

Is the service you are wanting to use documented anywhere?

nicosk
14 Jul 2010, 8:28 AM
Could you tell me how can i see the XML feed i am getting and how to debug my mappings and stuff? You've said it in a thread a while ago, but i can't find it...

Thank you,
Nicos

fay
14 Jul 2010, 9:09 AM
not its on a different server.


As you say that the XML you are accessing is on a different domain, do you not need to use ScriptTagProxy (http://www.sencha.com/deploy/dev/docs/?class=Ext.data.ScriptTagProxy) instead of HttpProxy (http://www.sencha.com/deploy/dev/docs/?class=Ext.data.HttpProxy)?

From the docs:


Note that if you are retrieving data from a page that is in a domain that is NOT the same as the originating domain of the running page, you must use this class, rather than HttpProxy.

See also: http://www.checkupdown.com/status/E501.html

Animal
14 Jul 2010, 9:26 AM
You can't use the ScriptTagProxy with a server that sends XML The server must send executable Javascript in response to a ScriptTagProxy's request.

nicosk, look in Firebug's Net tab.

And use Fiddler.

nicosk
14 Jul 2010, 11:02 AM
it could be a firefox issue, because when i use IE or Chrome (with Firebug lite) i don't get that error. But still my grid remains empty. I've changed my store to:


var liveScoreStore = new Ext.data.Store({
url: 'http://data2.xscores.com/exporter/?usr=user&pwd=pass',
autoLoad: true,
reader: new Ext.data.XmlReader({
record: 'Match',
//id: '@id'
},[
{id: 'id', mapping: '@id'},
//{name: 'home', mapping: '[email protected]'},
//{name: 'away', mapping: '[email protected]'}
])
});


and my grid to:


var mainTabPanel = Ext.getCmp('center-panel');
var tabExists = Ext.getCmp('liveScores');

if (!tabExists) {
mainTabPanel.add({
title: 'Live Scores',
margins: '0 5 5 5',
xtype: 'grid',
id: 'liveScores',
closable: true,
layout: 'fit',
columns: [
{ header: "Id", width: 50, dataIndex: "id" },
//{ header: "Home Team", width: 200, dataIndex: "home" },
//{ header: "Away Team", width: 200, dataIndex: "away" }
],
store: liveScoreStore
});
mainTabPanel.setActiveTab('liveScores');
}
else {
mainTabPanel.setActiveTab(tabExists);
}
//liveScoreStore.load();
}

Animal
14 Jul 2010, 11:19 AM
Is the returned Content-Type text/xml (or application/xml)?

nicosk
14 Jul 2010, 11:36 AM
well i don't really get any returns... :( even though i don't get any errors in Firebug console. So now i know why i don't get any data in my grid :)

But in DOM tab in FB i get the following errors:
1.No fallback url defined for this action. When defining a DataProxy api, please be sure to define an url for each CRUD action in Ext.data.Api.actions or define a default url in addition to your api-configuration.
2.Attempted to execute an unknown action. Valid API actions are defined in Ext.data.Api.actions"
3.received an invalid API-configuration. Please ensure your proxy API-configuration contains only the actions defined in Ext.data.Api.actions
4.Invalid url. Please review your proxy configuration.

Any ideas ?

muncher
14 Jul 2010, 11:40 AM
you can do one thing. Copy the xml in a local file and access that file. Just to see that your code (js) works atleast for the xml file.

nicosk
14 Jul 2010, 12:30 PM
Yeap, when i copied the file to localhost, it worked fine. Only a small mistake when i used { id: 'id', mapping: '@id' } instead of { name: 'id', mapping: '@id' }.

I know its not an EXTJS issue, but anyone knows anything about this 501 error?


Regards,
Nicos