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

  • Home
  • SEARCH
  • 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 9188547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:02:08+00:00 2026-06-17T20:02:08+00:00

I want to parse the URL of a weather API in my sample Android

  • 0

I want to parse the URL of a weather API in my sample Android app, but it arises an exception while parsing the url.

If I comment the last statement of the try block:

xr.parse(new InputSource(url.openStream()));

then my program runs successfully. Please revise my code where I parse my URL.

try {
    URL url;        
    String queryString ="http://free.worldweatheronline.com/feed/weather.ashx?q=34.01,71.54&format=xml&num_of_days=5&key=ccad66928f081759132201";

    url = new URL(queryString.replace(" ", "%20"));

    SAXParserFactory spf = SAXParserFactory.newInstance();
    SAXParser sp = spf.newSAXParser();

    XMLReader xr = sp.getXMLReader();

    WeatherHandler myWeatherHandler = new WeatherHandler();
    xr.setContentHandler(myWeatherHandler);

    xr.parse(new InputSource(url.openStream()));

    Log.d(TAG, "it's all right");
} catch (Exception e) {
    System.out.println(e);
    Log.d(TAG, "it's Wrong");
}

Here is the Screen shot of the log cat when the exception occurs.
enter image description here

  • 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-06-17T20:02:10+00:00Added an answer on June 17, 2026 at 8:02 pm

    Are you sure the line:

    new InputSource(url.openStream());
    

    from

    xr.parse(new InputSource(url.openStream()));
    

    is returning something? If you have to connect to the Internet, don’t forget to add the permissions to the manifest. And you should also test if you actually get something from that url before trying to parse.
    At least that’s my interpretation from your Log and Exception.

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

Sidebar

Related Questions

I want to parse the Weather API (URL) city name, temperature, etc. My JSON
i want to parse google weather API using NSXML so please give me some
I want to parse the url from a String in android. The example String
I want parse xml in windows store app with Xdocument. I tried this,but returned
I want show weather information from xml to this URL: http://www.google.com/ig/api?weather=roma&hl=it using this script:
I am making an android app. I want to open a url sent to
I want to parse a descriptive-style URL with slashes (such as server/books/thrillers/johngrisham/thefirm ), in
I use parse_url() to get the path of a url but i want to
i want to parse 1 url and afterwords i want to access some data
I am doing xml parsing while my url is authenticate url with username and

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.