We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › PARSING XML FROM WEBPAGE
Page Index Toggle Pages: 1
PARSING XML FROM WEBPAGE (Read 660 times)
PARSING XML FROM WEBPAGE
Jun 22nd, 2006, 1:15am
 
Hi,
I am trying to use some weather data to control an applet, for example BBC 5day london forecast.

http://www.mopoke.co.uk/weather/detailed/1769.xml

Is it possible to use proHTML or proXML for this? I have read somewhere that xml file must however reside within the data folder of sketch and not on a remote server. I dont really want to use PHP script running on some server for screen-scrapping and later updating a txt/html that processing could eventually read. Neither i want to use GNU Wget or alike to read remote xml files and update a locate txt/xml which processing then refers.
is there a simpler way to read remote xml?

second question is, even if i copy this xml and put it in data directory it doesnt seem to work.(have a look at the xml link). I only want to get windspeed and visibility data for current day into my processing project. However it seems  that all this information is packed under <discription> tag and is not clearly separated. Any idea, how to go about it?
if windspeed is "17MPH" how do i remove MPH from this information and feed 17 as number into a variable?
Any help | pointers | suggestions would be great.
Thank you in advance.
Sachin
Re: PARSING XML FROM WEBPAGE
Reply #1 - Jun 22nd, 2006, 5:31pm
 
I tried to open the file and it worked, I was also able to directly open the link from a localy runnig processing sketch.
You can use processings string functions to get the information you need from the description:

http://processing.org/reference/split_.html

Also check the java api for more string functions:

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html
Re: PARSING XML FROM WEBPAGE
Reply #2 - Jun 23rd, 2006, 1:08am
 
Thank you so much.
Actually i was able to read the XML through proHTML meanwhile and it worked really well directly from the link! - So now i know that this is now a matter of how to get the exact data out of XML and not wheather or not it would work.
I will have a go at it over the weekend.
Thank you once again.
Sachin
Page Index Toggle Pages: 1