I am developing a little application that grabs the weather from the Weather Channel’s XML weather service. Now, the weather channel doesn’t provide a typical SOAP service, so I just have it download the specific URL with a zipcode like this:
set theweather to do shell script "curl [url=http://xoap.weather.com/weather/local/]http://xoap.weather.com/weather/local/"[/url] & zip & "?cc=*\&prod=xoap\&par={1004016953}\&key={f9b8f04d93ba4fb0}"
Once it downloads I have a routine that strips out the weather “icon” which tells an app which icon to use, from a selection of about 50, to depict the weather. Now, once it is all finished I get this:
I simply need a way to remove the parts of the string, and leave me with the number, so that I can use that number elsewhere. Any ideas? I’m positive that it’s possible (without any scripting additions please) to do it. Thanks ahead of time.
P.s. I realize that there could be a thread on this somewhere, but I really don’t know what to search for. Sorry.
[/quote]
Close, now it returns “con>34” as the “num” variable. I think that I just have to tweak around with the numbers a little. If I get it I’ll let y’all know, otherwise keep any suggestions coming. Thanks!
I think that it is treating the <, >, and / characters as multiple characters, in ASCII or something like that. There isn’t anything more to the string that I didn’t post.
The only caveat with this script, jonn, is if the end delim appears in the string before the start delim, resulting in a different substring being returned. Admittedly I can’t think of a legitimate case off-hand, but it’s possible and therefore worth noting.
A slightly more robust version of your code would be:
You are right but there is still a problem in your code in the case that the start delimiter is not found in the text in which case there will be no text item 2 so I amended mine further: