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 2 of 2
Topic:
frustrating XML parsing problem - update: I GOT IT!!!
This thread has 17 replies. Displaying posts 16 through 18.
Post 16 made on Friday May 28, 2010 at 06:40
mikasound
Long Time Member
Joined:
Posts:
March 2010
15
I have some dificulities with E4X XML data standard. The code is:

----ProntoScript----
var httpLib = com.philips.HttpLibrary,url;

var url = "http://api....xml"


function ParseXML(xmldata)
{
var xmldata = xmldata.replace(/^<\?xml\s+version\s*=\s*(['"])[^\1]+\1[^?]*\?>/, "")
var xmlObject = new XML(xmldata);

System.print(xmlObject.disp.@stat);//nothing
System.print(xmlObject.disp.what.photo[0].description);//nothing
System.print(xmlObject);//all XML displays on _PS_DEBUG_ widget
}
httpLib.getHTTP(url, ParseXML);

----/ProntoScript----

the xml data is

--- XML ---- # == <

#?xml version="1.0" encoding="utf-8" ?>
#disp stat="ok">
#what>
#photo>
#description>Desc 1#/description>
#/photo>
#photo>
#description>Desc 2#/description>
#/photo>
#/what>
#/disp>

--- /XML ----


And nothing happens. What am I doing wrong?
milan
Post 17 made on Monday May 31, 2010 at 07:17
mikasound
Long Time Member
Joined:
Posts:
March 2010
15
Found the error. When calling a XML value skip the first element (wrapper).

xmlObject.disp.what.photo[0].description won't work but
xmlObject.what.photo[0].description

Use only nested elements isnside wrapper XML tag.
milan
Post 18 made on Monday May 31, 2010 at 16:29
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,992
I seem to recall something like this from reviewing the ECMA357 PDF a few years back. Kind of odd they did it this way but I think this was illustrated in one of the gray-box examples.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Page 2 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