//LatLon class
class LatLon {
float latitude = 0;
float longitude = 0;
//get lat
float getLat() {
return latitude;
}
//get lon
float getLon() {
return longitude;
}
//make the XML request
void requestLatLon() {
//get all xml source and put into a single string
String url = "http://timhibbard.com/webservices/engraphgps/engraph.asmx/GetTimsLocation";
String[] lines = loadStrings(url);
String xml = join(lines, " ");
//search for latitude
String lookforlat ="";
String endlat = "";
latitude = float(TextBetween(xml,lookforlat,endlat));
//search for longitude
String lookforlon ="";
String endlon = "";
longitude = float(TextBetween(xml,lookforlon,endlon));
}
//a function that returns a substring
String TextBetween(String s, String before, String after) {
String found = "";
int start = s.indexOf(before); //index of beginning tag
if (start==-1) return "";//if we don't find anything send back a blank string
start+=before.length();//move to end of beginning tag
int end = s.indexOf(after,start);//find end of end tag
if(end==-1) return ""; //if we don't find anything send back a blank string
return s.substring(start,end);
}
}