Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Topic:
Problem with XML data from TCP connection
This thread has 3 replies. Displaying all posts.
Post 1 made on Thursday January 8, 2009 at 17:15
Cremericon
Long Time Member
Joined:
Posts:
November 2003
10

Hi All

I am I progress of making a TV guide.

Until now it was going fine but my problem are like this.

I have formatted the TV contents as XML and was going for the E4X as described in the ProntoScript Developer’s Guide.

My problem is now that when I get the XML data from a homepage i am not able to use the root.chanal.@name.

But when I include the XML data in the script it works fine.

I have tried to use the example in the ProntoScript Developer’s Guide but with the same result.

My code looks like this:

var socket = new TCPSocket(false);

var result = "";

socket.onConnect = function(){

socket.write("GET /epg/GetEPG.php HTTP/1.1\r\nHost: www.hostname.dk\r\nConnection: Keep-Alive\r\n\r\n");

};

socket.onData = function(){

result += socket .read();

};

socket.onClose = function(){

var i=0;

var xmlStartIndex = result.indexOf("
var xmlStopIndex = result.indexOf("")+7;

var root = result.substring(xmlStartIndex ,xmlStopIndex );

widget("Res").label = body.content.@title;

}

socket.connect('hostname.dk', 80, 3000);

Any ideas on how to solve this problem?

Steen

Last edited by Cremericon on January 8, 2009 17:26.
Post 2 made on Thursday January 8, 2009 at 18:17
tenchi
Long Time Member
Joined:
Posts:
January 2006
156
From doing a fair amount of playing with XML stuff it doesn't quite look right.

I'll get back to you a bit later just about to head off to a meeting.
Post 3 made on Thursday January 8, 2009 at 18:26
tenchi
Long Time Member
Joined:
Posts:
January 2006
156
Ok providing

this bit:
var xmlStartIndex = result.indexOf(" //some missing code here??
var xmlStopIndex = result.indexOf("")+7;

Your chopping of the XML header the next step should be

body = new XML(result.substring(xmlStartIndex ,xmlStopIndex ));

Your probably wondering why did I use body =

Well the main reason is what ever you call it here is what the first node is. So for your own sanity name it the first node :)

The rest of your code should be ok from there.

All else fails pic up a copy of ProntoPic and analyse that code a bit more ;)

FYI I normally chop the <XML> header by using the name of the first node
eg.
var StartIndex = receivedData.indexOf("<body");
receivedData = receivedData.substring(StartIndex)
body = new XML(receivedData)
OP | Post 4 made on Friday January 9, 2009 at 15:57
Cremericon
Long Time Member
Joined:
Posts:
November 2003
10
Perfect,

It was the "new XML("")" that was missing. ;-)

Now it is working lika a charm.

Thanks for the quick response.


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse