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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:22:01+00:00 2026-05-13T09:22:01+00:00

I am using SAX to parse an XML file I’m pulling from the web.

  • 0

I am using SAX to parse an XML file I’m pulling from the web. I’ve extended DefaultHandler with code similar to:

public class ArrivalHandler extends DefaultHandler {    
    @Override
    public void startElement(String namespaceUri, String localName, String qualifiedName, Attributes attributes) throws SAXException {
        if (qualifiedName.equalsIgnoreCase("resultSet")) {
            System.out.println("got a resultset");
        } else if (qualifiedName.equalsIgnoreCase("location")) {
            System.out.println("got a location");
        } else if (qualifiedName.equalsIgnoreCase("arrival")) {
            System.out.println("got an arrival");
        } else {
            System.out.println("There was an unknown XML element encountered: '" + qualifiedName + "'");
        }        
    }

    @Override
    public void endElement(String namespaceUri, String localName, String qualifiedName) throws SAXException {
        // we'll just ignore this for now
    }

    @Override
    public void characters(char[] chars, int startIndex, int length) throws SAXException {
        // ignore this too
    }
}

The problem I’m having is that I’m just getting a series of empty elements. The log reads:

There was an unknown XML element encountered: ''
There was an unknown XML element encountered: ''
There was an unknown XML element encountered: ''
etc

This worked fine when I was just passing parser.parse a local file, but now I’m pulling it from the web with:

HttpClient httpClient = new DefaultHttpClient();
resp = httpClient.execute("http://example.com/whatever");

SAXParserFactory saxFactory = SAXParserFactory.newInstance();
ArrivalHandler handler = new ArrivalHandler();
SAXParser parser = saxFactory.newSAXParser();
parser.parse(resp.getEntity().getContent(), handler);

and I get the (apparently) empty results described above.

What I’ve looked into so far:

  1. I converted the InputStream from resp.getEntity().getContent() to a string and dumped it out and it looks like I’m getting the XML from the server correctly.
  2. There are no exceptions thrown but there is a warning that reads “W/ExpatReader(232): DTD handlers aren't supported.“.

Any other ideas for what I’m doing incorrectly or how to debug this?

  • 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-13T09:22:01+00:00Added an answer on May 13, 2026 at 9:22 am

    From the docs for ContentHandler.startElement:

    the qualified name is required when
    the namespace-prefixes property is
    true, and is optional when the
    namespace-prefixes property is false
    (the default).

    So, do you have the namespace-prefixes property set to true?

    Can you just cope with the uri and localName instead?

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

Sidebar

Ask A Question

Stats

  • Questions 490k
  • Answers 490k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer First of all, it's a really bad idea to use… May 16, 2026 at 9:17 am
  • Editorial Team
    Editorial Team added an answer If you are not dead set on using a listbox,… May 16, 2026 at 9:17 am
  • Editorial Team
    Editorial Team added an answer killproc will terminate programs in the process list which match… May 16, 2026 at 9:17 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a problem with using the SAX parser to parse a XML file.
I am trying to parse an XML file using the SAX interface of libxml2
I have student.xml file and am parsing this file using SAX Parser and now
I am trying to parse XML in Perl using XML::SAX parser . My query
I am a latecomer to XML - have to parse an XML file. Our
what are the best practices parsing XML from an HTTP resource in Android? I've
I am trying to use DOM Parser in Java to parse a small XML
<xml> <Office prop1=prop1 prop2=prop2> <Version major=1 minor=0/> <Label>MyObjectA</Label> <Active>No</Active> </Office> <Vehicle prop=prop> <Wheels>4</Wheels> <Brand>Honda</Brand>
I'm using CoreData (with SQLite as the store) in an iOS 4 iPhone application

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.