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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:09:42+00:00 2026-05-20T14:09:42+00:00

I’m writing an app for android that needs to parse data from an XML

  • 0

I’m writing an app for android that needs to parse data from an XML file. I’ve never come across an error like this that is so impossibly hard to track down. Or maybe my brain just stopped working. That happens. XML file is of the form:

<?xml version="1.0" encoding="iso-8859-1"?>
<memberRoster>
    <agent>
        <agentInfo1>...</agentInfo1>
        <agentInfo2>...</agentInfo2>
        ...
    </agent>
    <agent>
        ...
    </agent>
    ...
</memberRoster>

So far it’s working well, except for some random bits of fun!

Every now and then it will throw a NullPointerException. I did some more digging and found out that there are THREE “agents” (out of 800) with “supposedly” null data. I checked the XML file and the data is there, there are no illegal characters, etc. It is the same three “agents” every time. The program parses other entries before and after these “null” “agents”. Also of note is that not all “agentInfo” fields in the ArrayList come up null; example, one of the entries has 7 of the 8 entries as null, with the 8th one non-null, another has only one null with the last 7 non-null.

I’m parsing the data in to an ArrayList from the XML file, and like I mentioned before, it works flawlessly until it comes to those three specific entries in the XML file.

I’m sorry I can’t give much more info than that, the data is sensitive to our members.

EDIT:

Sorry! I knew I was forgetting something! 🙂

Some code from my XMLHandler.java class:

public void characters(char[] ch, int start, int length)

    if(this.in_mr_agentNrdsId) {
        agent[0] = ch.toString();
    }
    else if(this.in_mr_agentFirstName) {
        agent[1] = ch.toString();
    }
    else if(this.in_mr_agentLastName) {
        agent[2] = ch.toString();
    }
    else if(this.in_mr_agentPhone) {
        agent[3] = ch.toString();
    }
    else if(this.in_mr_agentEmail) {
        agent[4] = ch.toString();
    }
    else if(this.in_mr_agentOfficeName) {
        agent[5] = ch.toString();
    }
    else if(this.in_mr_agentOfficePhone) {
        agent[6] = ch.toString();
    }
    else if(this.in_mr_agentType) {
        agent[7] = ch.toString();
        pds.setMemberRoster(agent);
        agent = new String[8];
    }

PDS is an object of type ParsedDataSet, which is just a simple class containing the ArrayList objects and a few getter and setter methods:


public class ParsedDataSet {
private ArrayList agentOpenHouses = new ArrayList();
private ArrayList calendarOfEvents = new ArrayList();
private ArrayList latestStatistics = new ArrayList();
private ArrayList memberRoster = new ArrayList();

public ArrayList<String[]> getAgentOpenHouses() {
    return agentOpenHouses;
}

public ArrayList<String[]> getCalendarOfEvents() {
    return calendarOfEvents;
}

public ArrayList<String[]> getLatestStatistics() {
    return latestStatistics;
}

public ArrayList<String[]> getMemberRoster() {
    return memberRoster;
}

public void setAgentOpenHouses(String[] agentOpenHousesItem) {
    this.agentOpenHouses.add(agentOpenHousesItem);
}

public void setCalendarOfEvents(String[] calendarOfEventsItem) {
    this.calendarOfEvents.add(calendarOfEventsItem);
}

public void setLatestStatistics(String[] latestStatisticsItem) {
    this.latestStatistics.add(latestStatisticsItem);
}

public void setMemberRoster(String[] memberRosterItem) {
    this.memberRoster.add(memberRosterItem);
}

} // end class ParsedDataSet

  • 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-05-20T14:09:43+00:00Added an answer on May 20, 2026 at 2:09 pm

    You could throw an if statement into your assignements and reassign any caught ‘NULL’ or empty strings into a zero value or just reassign as variable = “” in your code.

    For example:

    if (agentInfo1 == NULL) {
        agentInfo1 = "" || agentInfo1 = 0; //Depending on what your variables are
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i want to parse a xhtml file and display in UITableView. what is the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a bunch of posts stored in text files formatted in yaml/textile (from
We're building an app, our first using Rails 3, and we're having to build

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.