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

The Archive Base Latest Questions

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

I am trying to parse an XML in Android and i get the following

  • 0

I am trying to parse an XML in Android and i get the following error

01-10 01:17:19.050: W/System.err(3276): java.lang.NullPointerException
01-10 01:17:19.050: W/System.err(3276):     at com.m7.nomad.XMLParsingActivity.parseCategoryXML(XMLParsingActivity.java:31)
01-10 01:17:19.050: W/System.err(3276):     at com.m7.nomad.XMLParsingActivity.onCreate(XMLParsingActivity.java:26)
01-10 01:17:19.050: W/System.err(3276):     at android.app.Activity.performCreate(Activity.java:4465)
01-10 01:17:19.050: W/System.err(3276):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
01-10 01:17:19.050: W/System.err(3276):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1932)
01-10 01:17:19.055: W/System.err(3276):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1993)
01-10 01:17:19.055: W/System.err(3276):     at android.app.ActivityThread.access$600(ActivityThread.java:127)
01-10 01:17:19.055: W/System.err(3276):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1159)
01-10 01:17:19.055: W/System.err(3276):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-10 01:17:19.055: W/System.err(3276):     at android.os.Looper.loop(Looper.java:137)
01-10 01:17:19.055: W/System.err(3276):     at android.app.ActivityThread.main(ActivityThread.java:4507)
01-10 01:17:19.055: W/System.err(3276):     at java.lang.reflect.Method.invokeNative(Native Method)
01-10 01:17:19.055: W/System.err(3276):     at java.lang.reflect.Method.invoke(Method.java:511)
01-10 01:17:19.055: W/System.err(3276):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
01-10 01:17:19.060: W/System.err(3276):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
01-10 01:17:19.060: W/System.err(3276):     at dalvik.system.NativeStart.main(Native Method)

Code

public class XMLParsingActivity extends SherlockActivity {

    AssetManager assetManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about);

        parseCategoryXML();
    }

    private void parseCategoryXML() {
        try {
            InputStream is = assetManager.open("categories.xml");

            SAXParserFactory spf = SAXParserFactory.newInstance();
            SAXParser sp = spf.newSAXParser();
            XMLReader xr = sp.getXMLReader();

            CategoriesXmlHandler catXMLHandler = new CategoriesXmlHandler();

            xr.setContentHandler(catXMLHandler);
            InputSource inStream = new InputSource(is);
            xr.parse(inStream);
            is.close();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

The error is being Pointed at this line

InputStream is = assetManager.open("categories.xml");
  • 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-17T08:13:03+00:00Added an answer on June 17, 2026 at 8:13 am

    assetManager is null.

    You defined the variable assetManager however you did not assign a value to it (at least not in the code you provided).

    You can use the AssetManger provided by the Activity. In this case can assign it in onCreate():

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        this.assetManager = this.getAssets();
    
        ...
    }
    

    See the getAssets() documentation.

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

Sidebar

Related Questions

I'm trying to parse xml done like this: <foreign lang=gre>&lsquo;<LM lemma=auieo catg=fg>auieo</LM>&rsquo;</foreign> I'm using
I'm trying to parse an XML coming from an php request URI: http://caracasfutbolclub.com/service/news.php .
I'm trying to parse this XML I want to get a list of all
I am trying to parse an XML file with python using lxml, but get
I'm trying to figure out how to parse some XML (for an Android app),
I'm trying to parse an XML document on Android 2.3.3, but it seems that
I'm trying to read and the XML response from the following url http://sagt.vizushop.com/DefaultSimple.aspx?command=default I
I'm trying to parse the XML HttpResponse i get from a HttpPost to a
I'm trying to parse XML with Android's own parser. I am using the IBM
So im trying to parse and xml file in android. Bellow is a link

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.