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

Login:
Pass:
 
 

Page 1 of 2
Topic:
frustrating XML parsing problem - update: I GOT IT!!!
This thread has 17 replies. Displaying posts 1 through 15.
Post 1 made on Tuesday April 8, 2008 at 21:04
Wishmaster
Long Time Member
Joined:
Posts:
March 2008
42
I am really frustrated!

I'm trying to parse this small XML content:

#tv generator-info-name="TV Movie zu XMLTV, Version 1.31">
#programme start="20080408000000 +0200" channel="ARD">
#title>Nachtmagazin#/title>
#/programme>
#/tv>


(had to replace the '<'s with #'s, otherwise it would be treated as HTML code in this forum)

my problem:
if I set the variable directly in my code like
myxml =
...xmldata...xmldata...
;

T = myxml.programme.title works

BUT if I load the XML-Data into the variable myxml throught a webserver and the tcp/ip socket, I get the error:
"ProntoScript error: TypeError: myxml.programme.title has no properties"

I checked it a hundred times, I get exactly the same data from the webserver (I let it display in a widget.label) as if I define the xml-content directly in my script. (sure: cutted off the header)

What the hell is wrong here????
I'm thankful for every tip!

Last edited by Wishmaster on April 9, 2008 21:35.
Post 2 made on Tuesday April 8, 2008 at 22:19
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,996
You must strip off the XML preprocessor instruction before passing to ECMA for evaluation. It is likely that the URL you are downloading from provides the preproc instruction.

For example,
Same convention, < replaced with #.
#?xml version="1.0">
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 3 made on Wednesday April 9, 2008 at 04:38
Sogliphy
Long Time Member
Joined:
Posts:
July 2007
186
You could try to duplicate your problem in Firefox, which also has E4X support:

<html>
<head>
<!-- note: need at least Firefox 1.5 for E4X to work-->
<script type="text/javascript; e4x=1">
function mytest()
{
var xmlString =
"<tv generator-info-name=\"TV Movie zu XMLTV, Version 1.31\">\n" +
"<programme start=\"20080408000000 +0200\" channel=\"ARD\">\n" +
" <title>Nachtmagazin</title>\n" +
"</programme>\n" +
"</tv>\n";
var myxml = new XML(xmlString);
alert(myxml.programme.title);
}
</script>
</head>
<body>
<form>
<input type="submit" onclick="mytest();" value="E4X test" />
</form>
</body>
</html>
OP | Post 4 made on Wednesday April 9, 2008 at 06:53
Wishmaster
Long Time Member
Joined:
Posts:
March 2008
42
I tried it w/ and w/o a "#?xml version="1.0">" header
I tried it by downloading directly a test.xml file from the server and also with a perl script printing the xml content - tried with content-type text/html, text/plain and text/xml - always the same problem.

When I print the xml content directly to a widget label, it always looks exactly the same - no matter if I defined the content with a variable in the script or if I fetch it with the tcp/ip socket function, but the ProntoScript XML-parser can only parse it without an error if defined as a variable.

I also tried it with a windows server and a unix server, removing the tabs, replacing the tabs with whitespaces, removing the breaks.

I also had a look at the weather script, but this script doesn't use the buit-in parser but works with .indexOf and .substring,... which is no pretty solution for me.

I'm not one of these, always starting a new thread if there is a little problem, but now I really got stucked with it and have no idea left :-(
OP | Post 5 made on Wednesday April 9, 2008 at 17:01
Wishmaster
Long Time Member
Joined:
Posts:
March 2008
42
@Lyndel McGee
"the url" I'm downloading from, is my own server - so it's me who says what get's transmitted :-) ... and I don't print the preproc instr. (also if I tried it with and without)

@Sogliphy
thanks, but this doesn't help a lot because, as I wrote, if I define the xml content directly in my ProntoScript, it works, but it doesn't if load the content via web.
OP | Post 6 made on Wednesday April 9, 2008 at 21:19
Wishmaster
Long Time Member
Joined:
Posts:
March 2008
42
What I found out:

this does work: ('#' = '<')
-----------------------------------------------
incomingdata =
#body>
#weather>
#vegas>sunny
#/weather>
#/body>
;
var body = incomingdata;
widget("myoutput").label = body.weather.vegas


but this doesn't: (the widget "myinput" holds the same data like in the variable - see above)
-----------------------------------------------
incomingdata = widget("myinput").label
var body = incomingdata;
widget("myoutput").label = body.weather.vegas




SO: could it be, that the ONYL way to define XML-content is:
variable =
...xml...
...xml...
;
first_xml_tag = variable;
parsed = first_xml_tag.content...... ????


I've tried it 4 nights long ...giving it up now!
Found now way to parse XML content if it's defined in an other way than like above within the ProntoScript code.


Any ideas left? :(
Post 7 made on Wednesday April 9, 2008 at 21:33
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,996
The only other thing I could suggest is to download the PDF for ECMA-357 and have a look @ the actual spec examples.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 8 made on Wednesday April 9, 2008 at 21:49
Wishmaster
Long Time Member
Joined:
Posts:
March 2008
42
*** I GOT IT !!!!! *** :D :D :D :D
*** I GOT IT !!!!! *** :D :D :D :D
*** I GOT IT !!!!! *** :D :D :D :D

what was missing: xmldata = new XML(parsed_web_content)

so:
after fetching the XML data from a webserver (or any other source) you have to "convert" it into "true" XML with "xmlPage = new XML(data)"
Then you can access the XML as usual.

"Thank you" Philips, for this "well" documented Development guide !!! :-(
Would it really have been this hard to leave a word about this command in the manual ???????

...since parsing XML makes only sense if you load it from a webserver or who would integrate XML in it's source code???


OH MAN! anyway ... I'm so happy now, that it works!
And I hope that I could help others too! (since e.g. the writer of the weather module also had to use a workaround with hundreds of IndexOf, substr,... to get the XML data)

So after 4 days spending my time finding out how to parse XML data, I can finally start my ProntoEPG project.
... which will also be "open source" like my ProntoTV

final words: HAPPY CODING, FRIENDS ! :-)
Post 9 made on Thursday April 10, 2008 at 17:02
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,996
Just my opinion but I feel it should be stated...

It is not Philips' responsibility to teach you ECMAScript nor is it their responsibility to educate you on the nuances of ECMA-357.

Now, OPINION OFF!!!!

I'm glad to see you found the XML constructor. I did not even think about this as I presumed you'd know to use this if you could not do inline variable declaration.

XML manipulation via ECMA has its own quirks. Just be glad you did not have namespace qualified data in your document. If you did, you'd be accessing nodes via namespaces.

I have encountered this because I, too wrote a module to access Yahoo/Weather Channel RSS xml feed and had to access data from various namespaces to make this work. It can be done rather easily and quite nicely. But, it does take some time getting used to working with XML namespaces in ECMA. For further reading, search the ECMA357 PDF for the string "set default namespace".
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 10 made on Wednesday April 23, 2008 at 06:41
mbienz
Lurking Member
Joined:
Posts:
March 2008
2
Sirs, I would like to create my first reply / post in this form. I am not new to Pronto but new to the 9600 and I just started to dev. a few things.

@ Wishmaster (especiall), I see you started / will start to dev an XMLTV or similar to Pronto application. I did already kind of a beta study (but 100% workable and customisable). Server in .net 2008 (vb) plus xmltv (autoupdate) and a little (basic and simple) xcf to receive the data. So at the moment am able to get the listing from XMLTV for Switzerland on my Pronto which is aboslutely NICE. Try to post a picture of it tonight / Friday (what's on feature with progress indicator + you can skip fwd and bkwd in program entries).

I am pretty sure that there are others also interested in this feature (but probably only Europe?). If yes I will be happy to post (send) both XFC and the server to have you test it.

Maybe we should open a seperate thread for that...

Last edited by mbienz on April 23, 2008 16:49.
TSU9600
Post 11 made on Wednesday April 30, 2008 at 05:22
johanj
Long Time Member
Joined:
Posts:
January 2008
52
mbienz, XMLTV for the Pronto is really interesting for me. I'm in sweden so I guess it should work for me. Do you have an XCF for the Pronto 9400?

Johan
Post 12 made on Thursday May 1, 2008 at 16:16
JazzMann
Lurking Member
Joined:
Posts:
May 2008
7
Sorry
JazzMann
Post 13 made on Thursday May 1, 2008 at 16:18
JazzMann
Lurking Member
Joined:
Posts:
May 2008
7
On April 23, 2008 at 06:41, mbienz said...

I am pretty sure that there are others also interested
in this feature (but probably only Europe?). If yes I
will be happy to post (send) both XFC and the server to
have you test it.

Maybe we should open a seperate thread for that...

Yea mbienz,
I would really like to try it out.

..:: Wishmaster ::..
Yeeeea Wether info on the remote, that could me totally coool

This is new to me, but very interresting

mx @ rolli dot dk
JazzMann
Post 14 made on Friday June 13, 2008 at 06:01
johanj
Long Time Member
Joined:
Posts:
January 2008
52
Wishmaster,mbienz what is the status of XMLTV for Pronto. Will it be available for the 9400?

A custom installer in Sweden offer a tv-guide for the 9600 version, I don't know if they developed it by themself.
Post 15 made on Friday June 13, 2008 at 11:25
linki
Lurking Member
Joined:
Posts:
June 2008
6
I am also very interested in a TV_guide for the 9600. I am located in the UK.

So guys now is the time to show off ;-) LOL, on a more serious note I really respect all programmers who are active on this forum! Thanks guys (you know who I mean)
Page 1 of 2


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