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 6346997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:07:27+00:00 2026-05-24T21:07:27+00:00

I am making a program for Windows phone that will get weather data from

  • 0

I am making a program for Windows phone that will get weather data from a xml file and display it on screen. However, I keep getting null values and I am not sure what I am doing wrong.

Sample XML file: http://forecast.weather.gov/MapClick.php?lat=44.52160&lon=-87.98980&FcstType=dwml

Here is what I have:

try
{
    // get the stream containing the response from the async call
    streamResult = forecastState.AsyncResponse.GetResponseStream();

    // load the XML
    XElement xmlWeather = XElement.Load(streamResult);

    // find the source element
    XElement xmlCurrent = xmlWeather.Descendants("source").First();

    // get city and height
    xmlCurrent = xmlWeather.Descendants("location").First();
    mTempCityName = (string)(xmlCurrent.Element("city"));
    mTempHeight = (int)(xmlCurrent.Element("height"));

    //Find the forecast time
    xmlCurrent = xmlWeather.Descendants("time-layout").First();

    //store time of day in array
    mTimeOfDay = (string)(xmlCurrent.Attribute("period-name"));

    //Find the temperature
    xmlCurrent = xmlWeather.Descendants("temperature").First();
    mTemp = (int)(xmlCurrent.Element("value"));

    //now get the current weather conditions for each time period
    xmlCurrent = xmlWeather.Descendants("weather").First();
    mDescription = (string)(xmlCurrent.Attribute("weather-summary"));

    //now get icon links for weather
    xmlCurrent = xmlWeather.Descendants("conditions-icon").First();
    mIcon = (string)(xmlCurrent.Attribute("icon-link"));
}
  • 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-24T21:07:28+00:00Added an answer on May 24, 2026 at 9:07 pm

    Well:

    • time-layout doesn’t have an attribute called period-name (it has subelements with that attribute)
    • temperature should be okay, I think
    • weather doesn’t have a weather-summary attribute – it has subelements with that attribute
    • conditions-icon doesn’t have an icons-link attribute, it has icons-link elements

    In other words, for each bit you need to look at exactly what the XML contains, and then exactly what you’re asking for, being careful to distinguish between elements and attributes.

    Note that for the values you’re casting to int (which don’t need extra brackets around them, btw) you should be getting an exception in this case – you clearly can’t be getting actual null values. Is it possible that an exception is being thrown and you’re not noticing it? What’s in your catch block?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a program that reads and stores data from Windows EventLog files
I'm making a program that will display a few images from a directory beside
I am making a small program in C# for Windows Phone. One thing that
I'm making a program that retrieves decently large amounts of data through a python
I am trying to learn python and am making a program that will output
I'm making a C program where I need to get the directory that the
I am making a program in C++ for Windows XP that requires sound to
I'm making a program that asks for a path, and Windows' paths contain backslashes,
I'm making a program that is using Windows Shell Integration, and the registry changes
I'm currently learning Windows/DOS assembly. I'm just making a small program that adds two

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.