Hi - I have my fingers crossed that someone can help. I'm trying to use a webservice (http://www.webservicex.net/WS/WSDeta...TID=12&WSID=56
) to get regional weather information. The problem I am having is that I don't know how to extract the data from the XML document which is returned. For example, if I get the weather in Reykjavik, Iceland using the webservice, the result returned is:
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://www.webserviceX.NET"><?xml version="1.0" encoding="utf-16"?> <CurrentWeather> <Location>Reykjavik, Iceland (BIRK) 64-08N 021-54W 61M</Location> <Time>Mar 16, 2006 - 10:00 AM EST / 2006.03.16 1500 UTC</Time> <Wind> from the S (170 degrees) at 14 MPH (12 KT):0</Wind> <Visibility> greater than 7 mile(s):0</Visibility> <SkyConditions> mostly cloudy</SkyConditions> <Temperature> 48 F (9 C)</Temperature> <DewPoint> 42 F (6 C)</DewPoint> <RelativeHumidity> 81%</RelativeHumidity> <Pressure> 30.50 in. Hg (1033 hPa)</Pressure> <Status>Success</Status> </CurrentWeather></string>
The problem I am having is that the ONLY information I need is the <Temperature> and the <SkyConditions> and I don't know how to extract just these two pieces of information to display on my site.
At the moment I use the webservice inside a class. I am successfully calling the webservice (I think), however, as I said, I don't know how to just get the data that I want from the result:
Public Class Facts
Private weather As New GlobalWeather()
Function getWeatherCond() As String
Dim strWeather As String
strWeather = weather.GetWeather("Reykjavik", "Iceland")
...unsure from here on in....
Protected Overrides Sub Render(writer As HtmlTextWriter)
To be honest, the only way I have got it to work for me (based on my knowledge) is to use a substring to find the appropriate tag. For example, for the <Temperature> I use:
Dim intTempStart As Integer = strWeather.IndexOf("<Temperature>", intStartPoint) + 14
Although this works, I'm guessing there is a better way to do this which is more effective. I've searched Google for any information and can't find anything, so am now hoping that someone here can help. I'm not sure if it has to do with how I am calling the webservice?
Thanks so much in advance for any help - and I hope this makes sense!