Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6929365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:18:28+00:00 2026-05-27T11:18:28+00:00

I am writing a Windows Phone 7 app to pull weather data from WeatherBug’s

  • 0

I am writing a Windows Phone 7 app to pull weather data from WeatherBug’s API. I’m running into problems with the 7 day forecast data. I am getting the data in XML but I can’t parse the XML data.

Here is the code that calls the web service and passes the zip code:

public void GetForecastByZip(string zip)
    {         
        string url = ("http://" + apiCode + ".api.wxbug.net/getForecastRSS.aspx?ACode=" + apiCode + "&zipCode=" + zip);            

        WebClient xmlClient = new WebClient();
        xmlClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(XMLFileLoaded);
        xmlClient.DownloadStringAsync(new Uri(url));
    }

And here is the code where I am getting the XML and attempting to do… something with it.

void XMLFileLoaded(object sender, DownloadStringCompletedEventArgs e)
    {
        if (e.Error == null)
        {
            string xmlData = e.Result;
            XmlReader reader = XmlReader.Create(xmlData);

            XDocument doc = XDocument.Load(reader);

        }
    }

The format of the XML is like so:

<rss version="2.0" xmlns:georss="http://www.georss.org/georss">
  <channel>
<title>Forecast for Williston Park, NY - USA</title>
<link>http://weather.weatherbug.com/NY/Williston Park-weather/local-forecast/7-day-forecast.html?ZCode=Z5546&amp;Units=0</link>
<description>Weatherbug, the owner of the world's largest weather network is now providing an API to it's weather data in the
    form of RSS.  This will enable it's enthusiastic users to build their own applications.</description>
<language>en-us</language>
<lastBuildDate>Wed, 07 Dec 2011 20:56:00 GMT</lastBuildDate>
<ttl>60</ttl>
<aws:weather xmlns:aws="http://www.aws.com/aws">
<aws:api version="2.0" />
<aws:WebURL>http://weather.weatherbug.com/NY/Williston Park-weather/local-forecast/7-day-forecast.html?ZCode=Z5546&amp;Units=0</aws:WebURL>
<aws:forecasts type="Detailed" date="12/7/2011 3:56:00 PM">
    <aws:location>
        <aws:city>Williston Park</aws:city>
        <aws:state>NY</aws:state>
        <aws:zip>11596</aws:zip>
        <aws:zone>NY179</aws:zone>
    </aws:location>
    <aws:forecast>
        <aws:title alttitle="WED">Wednesday</aws:title>
        <aws:short-prediction>Rain</aws:short-prediction>
        <aws:image isNight="1" icon="cond014.gif">http://deskwx.weatherbug.com/images/Forecast/icons/cond014.gif</aws:image>
        <aws:description>Wednesday</aws:description>
        <aws:prediction>Rain. Highs in the upper 50s. North winds 5 to 10 mph with gusts up to 20 mph. Chance of rain near 100 percent.</aws:prediction>
        <aws:high units="&amp;deg;F">59</aws:high>
        <aws:low units="&amp;def;F">31</aws:low>
    </aws:forecast>
    <aws:forecast>
        <aws:title alttitle="THU">Thursday</aws:title>
        <aws:short-prediction>Sunny</aws:short-prediction>
        <aws:image isNight="0" icon="cond007.gif">http://deskwx.weatherbug.com/images/Forecast/icons/cond007.gif</aws:image>
        <aws:description>Thursday</aws:description>
        <aws:prediction>Sunny. Highs in the lower 40s. West winds 15 to 20 mph... Diminishing to 5 to 10 mph in the afternoon.</aws:prediction>
        <aws:high units="&amp;deg;F">43</aws:high>
        <aws:low units="&amp;deg;F">35</aws:low>
    </aws:forecast>

etc., etc.

The aws:forecast section occurs seven times – once for each day in the forecast. Each iteration of it has the title, short-prediction, image, description, prediction, high, and low elements.

I have a Windows Phone pivot page entitled Forecast.xaml with seven items. I’m aiming for a display like so for each day:
“City: Williston Park”
“Date: 12/7/2011”
“Day: Wednesday”
“Description: Rain”
“Prediction: Rain. Highs in the upper 50s. North winds 5 to 10 mph with gusts up to 20 mph. Chance of rain near 100 percent.”
“High: 59”
“Low: 31”

Nothing fancy. But I just can’t figure out a way to pull the individual elements from the file and assign them to a variable.

I’ve read the tutorial at Kotan Code, but I’m having trouble applying it to my project. Any help would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:18:29+00:00Added an answer on May 27, 2026 at 11:18 am

    You can use Linq to XML – only make sure that you declare and use the right namespace, in this case aws as defined in your XML:

    ..
    XDocument doc = XDocument.Load(reader);
    XNamespace aws = "http://www.aws.com/aws";
    
    var forecasts = doc.Descendants(aws + "forecast")
                       .Select(x => new
                        {
                           Title = x.Element(aws + "title").Value,
                           ShortPrediction = x.Element(aws + "short-prediction").Value,
                           Prediction = x.Element(aws + "prediction").Value,
                           //more here
                        })
                       .ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a Windows Phone Mango app. I have a hyperlink that contains email
I'm writing a windows phone app that consist of a pivot control, and I
I'm writing a windows phone app, and I want to know how to alert
I'm writing a Windows Phone app in C#. I have a setting OrientationLock that
I'm writing an augmented reality app for Windows Phone 7 as a school project.
I'm writing a Windows Phone 7 app that needs to be location aware. Specifically
I am writing an app which allows users to enter some data into their
I am writing a Windows 7 Phone App on Visual Studio Express, and I
I'm trying to build JPG upload functionality into our Windows Phone app. The server-side
I'm writing an app for the Windows Phone 7 and although I think I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.