Forecast 'High' 'Low' XML parsing error

  • 1
  • Problem
  • Updated 3 years ago
I get a curly bracket and the word farenheit and a semi colon before the number that I'm interested in. This is the same for high and low temperature forecasts. I've looked over the API docs to check if I'm using the wrong xml response parameters in my parsing code, but I don't see anything obvious. Incidentally, current temperature parses correctly!
Photo of Mickey

Mickey

  • 2 Posts
  • 0 Reply Likes

Posted 3 years ago

  • 1
Photo of Ravi Yadav

Ravi Yadav

  • 82 Posts
  • 9 Reply Likes
What does your request URL look like? and can you share a screenshot of the response?
Photo of Mickey

Mickey

  • 2 Posts
  • 0 Reply Likes
GET /api/" + myKey + "/condition/forecast/q/autoip.json HTTP/1.1

I've not put in 'myKey' so as not to share it publicly, but it is in my actual program!

I'm using the program from https://gist.github.com/acturcato/8352621

Photo of Ravi Yadav

Ravi Yadav

  • 82 Posts
  • 9 Reply Likes
Thanks for sharing that. 

First, here is some documentation on current conditions and forecast: 
Current Conditions:  http://api.wunderground.com/weather/api/d/docs?d=data/conditions
Forecast:  http://api.wunderground.com/weather/api/d/docs?d=data/forecast

For you use case, temp_c comes from the Conditions API. You are able to parse that correctly because the response has separate attributes for temperatures in Celsius and Fahrenheit; temp_c and temp_f. 

Here is how low and high from the forecast API looks like:

high: 
{
    fahrenheit: "61",
    celsius: "16"
}