o:o
YaBB Newbies
Offline
Posts: 3
Re: iterating past empty rss feeds
Reply #2 - Jun 16th , 2009, 3:52pm
Thank you NoahBuddy. I have tried a few try and catch block, but i have to say i am not so familiar with them. Here is a stripped down version of the problem i am hoping to solve: As you press enter, at some point it will crash, therefore the initial question. Maybe you or someone could help me with the following code. Thank you. o:o note: i have taken out "http" from the url as i am told i need 5 posts before sending a web link. import processing.xml.*; PFont f_s, f_m, f_l; int x=1; void setup() { size(800, 600); f_s= createFont("SanSerif", 12); f_m= createFont("SanSerif", 16); f_l= createFont("Calibri_bold", 22); } void draw() { background(0); // try{ String url= //magicseaweed.com/syndicate/rss/index.php?id="+ x + "&unit="; XMLElement report= new XMLElement (this, url); //if(report!=null){ //println(report); // } // } //catch(IOException e){ // x++; // } ////////////////////////////////////////////////////////////////////// //Get the location // "<link>/Newquay-Fistral-Surf-Report/1/</link>" XMLElement Location= report.getChild("channel/title"); // println(Location); String locationStg= giveTextInBetween( Location.getContent(), "Latest", "Surf"); XMLElement reportNum= report.getChild("channel/link"); String reportNum2= giveTextInBetween( reportNum.getContent(), "Report/", "/"); //println(reportNum2); String Num= nf(parseInt(reportNum2), 4 ); // println(Num); textFont(f_l); fill(255); text(Num + ": " + locationStg, 10, 25); } //function taken from D.Shiffman String giveTextInBetween (String s, String startTag, String endTag){ String found= ""; int startIndex= s.indexOf(startTag); if(startIndex==-1) return ""; startIndex += startTag.length(); int endIndex= s.indexOf(endTag, startIndex); if(endIndex==-1) return ""; return s.substring(startIndex, endIndex); } void keyPressed(){ if (key== '\n'){ x= (int)random(1, 1062); } }