I've decided to look again at mister shiffmans simpleML library again, which I looked at briefly in my twitter top project, and found that not only am I a complete berk for not spotting the re-request HTML/XML command which I wanted so desperately and caused me annoyance when I couldn't figure it out myself, but that although it will save my program looking through the whole document, and therefore speed it up, it might still be not as useful as I'd like.
here's the BBC RSS feed for Leeds at the moment:
here's the bit that I'm interested in:
(Temperature: 9°C (48°F), Wind Direction: SW, Wind Speed: 40mph, Relative Humidity: 66%, Pressure: 987mB, rising, Visibility: Good)
Unfortunately, all the juicy bit I'm interested in is all in the same XML tag, so I can't use simpleML to all it's useful yummyness.
This causes a little problem with the words I'm using in my script. For example, "sunny" and "sunny intervals" both contain the word "sunny" so my script will see "sunny intervals" as "sunny". If that makes sense. The script I'm using at the moment is based on a script I used in my last project:
//pulling in feed of weather in stornoway
String[] tokens; //array
int counter;
void setup() {
size(100, 100);
//load file and split up words
String[] lines = loadStrings("http://news.bbc.co.uk/weather/forecast/373/ObservationsRSS.rss");
String allText = join(lines, " ");
tokens = splitTokens(allText, " ,.?!:;[]-");
}
//so it's now pulling in that sentence and splitting it up.
void draw() {
background(255);
fill(0);
String s = tokens[counter];
counter = (counter +1) % tokens.length;
//look at the words one at a time please
//is the word there?
if (s.equals("sunny")) {
println("sunny");
noLoop(); //DON'T LOOP IT BAHBEE.
}
if (s.equals("white")) {
println("white cloud");
noLoop(); //DON'T LOOP IT BAHBEE.
}
if (s.equals("grey")) {
println("grey cloud");
noLoop(); //DON'T LOOP IT BAHBEE.
}
if (s.equals("light")) {
println("light rain");
noLoop(); //DON'T LOOP IT BAHBEE.
}
if (s.equals("heavy")) {
println("heavy rain");
noLoop(); //DON'T LOOP IT BAHBEE.
}
if (s.equals("clear")) {
println("clear sky (night)");
noLoop(); //DON'T LOOP IT BAHBEE.
}
}
Now i just need to simpleML it up.
7.5.09
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment