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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:40:35+00:00 2026-06-06T13:40:35+00:00

I want to read an .xml file from a web radio for my app.

  • 0

I want to read an .xml file from a web radio for my app.

I’ve used this tutorial: http://www.androidhive.info/2011/11/android-xml-parsing-tutorial/

This is the function:

public String leggi_palinsesto(){
    XMLParser parser = new XMLParser();
    String xml = parser.getXmlFromUrl(URL); // getting XML
    Document doc = parser.getDomElement(xml); // getting DOM element

    NodeList nl = doc.getElementsByTagName(KEY_ITEM);

    // looping through all item nodes <item>
    for (int i = 0; i < 1; i++) {
        Element e = null;
        String titolo = parser.getValue(e, KEY_TITOLO); // name child value
        String artista = parser.getValue(e, KEY_ARTISTA); // cost child value

        System.out.println(artista+" - "+titolo);
    }

    return titolo+" "+artista;
}

But when arrive to NodeList nl = doc.getElementsByTagName(KEY_ITEM); the app crashes.

This is the logcat:

06-28 18:27:58.089: E/AndroidRuntime(1050): FATAL EXCEPTION: main
06-28 18:27:58.089: E/AndroidRuntime(1050): java.lang.NullPointerException
06-28 18:27:58.089: E/AndroidRuntime(1050):     at it.axiomatic.radioamicizia.RadioAmiciziaActivity.leggi_palinsesto(RadioAmiciziaActivity.java:315)
06-28 18:27:58.089: E/AndroidRuntime(1050):     at it.axiomatic.radioamicizia.RadioAmiciziaActivity$1$1.run(RadioAmiciziaActivity.java:122)
06-28 18:27:58.089: E/AndroidRuntime(1050):     at android.os.Handler.handleCallback(Handler.java:587)
06-28 18:27:58.089: E/AndroidRuntime(1050):     at android.os.Handler.dispatchMessage(Handler.java:92)
06-28 18:27:58.089: E/AndroidRuntime(1050):     at android.os.Looper.loop(Looper.java:123)
06-28 18:27:58.089: E/AndroidRuntime(1050):     at android.app.ActivityThread.main(ActivityThread.java:4627)
06-28 18:27:58.089: E/AndroidRuntime(1050):     at java.lang.reflect.Method.invokeNative(Native Method)
06-28 18:27:58.089: E/AndroidRuntime(1050):     at java.lang.reflect.Method.invoke(Method.java:521)
06-28 18:27:58.089: E/AndroidRuntime(1050):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-28 18:27:58.089: E/AndroidRuntime(1050):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-28 18:27:58.089: E/AndroidRuntime(1050):     at dalvik.system.NativeStart.main(Native Method)

This is the constant:

static final String URL = "http://www.radioamicizia.com/demo.xml";
    // XML node keys
    static final String KEY_ITEM = "song"; // parent node
    static final String KEY_TITOLO = "Title";
    static final String KEY_ARTISTA = "Artist";

Could someone please help me with this problem.

  • 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-06T13:40:37+00:00Added an answer on June 6, 2026 at 1:40 pm

    The doc variable is null, and so attempting to call getElementByTagName on it throws the NPE.

    It comes from the parser.getDomElement(xml) or before it.

    In short, make sure you followed the tutorial in full and your XmlParser class is exactly as in the tutorial and the methods dont return null.

    Also, learn to attach a debugger to your process, set a breakpoint, and inspect your code that way, I suggest you use Intellij community edition,i ts quite easy. 🙂

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

Sidebar

Related Questions

in my web.xml i want to read the welcome file from property file something
I'm trying to read the following xml file from spotify: http://ws.spotify.com/search/1/track?q=sail+awolnation I want to
Hi I can't understand this error I want read this XML file: <?xml version=1.0
I want to read an xml file placed in assets/ directory. I've tried this
I want these XML values read from the web service to a TextBlock ,
I want my app.config (or my web.config for that matter) to read from an
I want to read a XML file from a certain link with the following
I want to read an XML file from an URL and I want to
I want to read the following XML file received from my e-commerce site and
I want to read all XML contents from a file. The code below only

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.