Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 16th, 2006, 12:27 PM
Authorized User
Join Date: May 2005
Location: , , .
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Extract data from the XML result of a web service

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
  Inherits Control

  Private weather As New GlobalWeather()

  Function getWeatherCond() As String
    Dim strWeather As String
        strWeather = weather.GetWeather("Reykjavik", "Iceland")

    ...unsure from here on in....

  End Function


  Protected Overrides Sub Render(writer As HtmlTextWriter)
    writer.write(getWeatherCond("Reykjavik","Iceland") )
  End Sub
End Class

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!


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
xml text reader from Web Service djcowbell .NET Web Services 4 June 27th, 2007 08:40 AM
how to show result of MS Analysis service to WEB? rosejeep C# 0 November 8th, 2006 09:27 PM
Extract data and create xml for input dhol General .NET 1 February 2nd, 2005 03:01 PM
How to send an xml to a web service agbeltekin General .NET 0 May 10th, 2004 09:44 AM

All times are GMT -4. The time now is 09:07 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.