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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:38:09+00:00 2026-05-16T10:38:09+00:00

I have the following code in a few activities and it reads and parses

  • 0

I have the following code in a few activities and it reads and parses XML files fine but in two activities when reading small XML files I get a null pointer exception and can’t figure out what the problem is:

while (eventType != XmlResourceParser.END_DOCUMENT) {
    if ((eventType == XmlResourceParser.START_TAG) ||
        (eventType == XmlResourceParser.TEXT)) {
        // Get the name of the tag (eg scores or score)
        String strName = xmlSymptoms.getName();
        if (helpFound == 1){
            helpText  = xmlSymptoms.getText();
            helpFound = 0;
        } else if (strName.equals("string") && (eventType == XmlResourceParser.START_TAG)) {
            helpFound = 1;
        }

    }
    eventType = xmlSymptoms.next();
}

The null pointer exception occurs when I am reading in “<string>” which I am able to read in with the same code in other activities. In this activity, I am able to read in the other XML tokens fine until I get to “<string>“.

Here is my debug window

Thread [<1> main] (Suspended)
ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2628
ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2679
ActivityThread.access$2300(ActivityThread, ActivityThread$ActivityRecord, Intent) line: 125
ActivityThread$H.handleMessage(Message) line: 2033
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4627
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object…) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 868
ZygoteInit.main(String[]) line: 626
NativeStart.main(String[]) line: not available [native method]
Thread [<6> Binder Thread #2] (Running)
Thread [<5> Binder Thread #1] (Running)

I have LogCat running, but nothing shows up in it.

Here is some XML that works:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>A</key>
<array>
        <string>ABANDONED, feeling:     </string>
        <string>ABSCESS:        </string>
</array>
</dict>
</plist>

and here is some XML that doesn’t work:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"   "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>HOWTOTAKE</key>  
  <array>
  <string> Put two pellets in 8 oz bottle of water.</string>
  </array>
</dict>
</plist>

One last note: When I get to the “<string>” field, getName() returns “null” instead of “string”. Obviously trying to tell me something, I just can’t figure out why “null” is returned.

Any ideas how to debug this?

  • 1 1 Answer
  • 2 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-16T10:38:10+00:00Added an answer on May 16, 2026 at 10:38 am

    I figured out what the problem was. Since I am looking for XmlResourceParser.TEXT, strName.equals(“string”) is null when (eventType == XmlResourceParser.TEXT) is true. Changing the code to only check for (strName.equals(“string”) when (eventType == XmlResourceParser.START_TAG) is true, fixed the problem as shown in the code below:

    while (eventType != XmlResourceParser.END_DOCUMENT) {
        if ((eventType == XmlResourceParser.START_TAG) ||
            (eventType == XmlResourceParser.TEXT)) {
            // Get the name of the tag (eg scores or score)
            String strName = xmlSymptoms.getName();
            if (helpFound == 1){
                helpText  = xmlSymptoms.getText();
                helpFound = 0;
            } else if ( (eventType == XmlResourceParser.START_TAG)) {
                if (strName.equals("string") ){
                    helpFound = 1;
                }
            }
    
        }
        eventType = xmlSymptoms.next();
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code files: public interface IMod { string Name { get;
I have following code. It works fine in firefox but is not working in
I have the following code to create and apply a few styles for a
I have following code <div id=main> <div id=one> </div> <div id=two> </div> <div id=three>
I have following code for loading image from url in xml parsing endElement method
I have the following code where I am trying to add a few Kineticjs
I have the following code that I'm trying to get working. What I want
i have the following code, right now just a logo in a div, but
Again in problem Actually I have following jsp code in which I have few
I have following code in initialization im = imread('Image02.tif'); figure(); imagesc(im); colormap(gray); [hImage hfig

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.