Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Getting Information off a website question

Ruboneout Shoreman
Registered User
Join date: 29 Jul 2009
Posts: 38
02-05-2010 00:03
Soo lately, Ive been looking into having a prim display weather information from a particular real world location. With this in mind, i came across the google weather api. When you type in the location as part of the URL, it'll display an XML page containing all of the data I need. Like the forecast, the current conditions, temps etc...

Then i'm going to make a script that will parse and gather all of the information that I want. This seems really long and tedious though... I was wondering if there is a better way to approach this situation, or if this is a decent way. I'm just happy I figured it out on my own :O.

Thanks.

EDIT: http://www.google.com/ig/api?weather=new+york,ny this is an example of it, if you would like to see for what ever reason.
Laurie Stilman
Registered User
Join date: 11 Apr 2006
Posts: 45
02-05-2010 01:04
There is some code knocking around on the wiki or one of the other script libraries that does primitive parsing of XML, but it's not a data format LSL is good at processing... You may be able to request the data if a format more easily digested by LSL (CSV would be good :-), or you may be able to request the XML through some sort of proxy that will trasform the XML for you.

Failing that, it may be safe to make some assumptions about the XML and just use simple string comparison and slicing operations to parse the data out. That would probably work in this case, and would only be a little bit long and tedious... :)
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-05-2010 01:07
grabbing that page and parsing it looks to be pretty optimal, it's reported size is only <1/4 of the maximum bytes you can view so that should be fine... if you run into a situation where you are getting a page with needed data that's past the 2048 byte mark, you can instead request a search via google of the page, and the exact element you need

ETA:
you might be able to do the same thing via XML/RPC but it's been deprecated and has problems with frequent use
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -