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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:04:10+00:00 2026-06-01T20:04:10+00:00

I have found twofold treatment of XmlPullParser.END_DOCUMENT tag in Android’s built-in SAX parser. Code

  • 0

I have found twofold treatment of XmlPullParser.END_DOCUMENT tag in Android’s built-in SAX parser. Code is simple:

    String s; //actually contains XML
    //blah-blah
    factory = XmlPullParserFactory.newInstance();
    factory.setNamespaceAware(false);
    xpp = factory.newPullParser();
    StringReader sw=new StringReader(s);
    xpp.setInput(sw);
    int eventType = xpp.getEventType();
    while (eventType != XmlPullParser.END_DOCUMENT)
    {
        if (eventType == XmlPullParser.START_TAG)
        {
               //blah-blah
        }
        else if(eventType==XmlPullParser.TEXT)
        {
               //blah-blah
        }
        else if (eventType == XmlPullParser.END_TAG)
        {
               //blah-blah
        }
        eventType=xpp.next();
    }

If XML document basically looks like (String s):

<?xml version="1.0" encoding="utf-8"?>
<templates>
    <template key="Person" name="Person">
        <field key="Photo" name="Photo" type="image" hint="Press to select image"/>
    </template>
</templates>

With this everything works fine. But if there are some extra characters after final tag </templates> – here goes weird side (nature of my XML is such that sometimes there can appear some litter symbols after final tag).

For nearly all Android devices (about 90%) SAX parser ignores extra characters, but in some of devices – mostly devices with ICS – SAX parser tries to parse extra characters and crashes.

So the question is: what says XML standard? Should SAX parser try to parse extra symbols after final tag? And what anyway is XmlPullParser.END_DOCUMENT – it’s either end of data or just final tag?

  • 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-01T20:04:11+00:00Added an answer on June 1, 2026 at 8:04 pm

    If there are non-whitespace characters after the end tag of the root element, the file is not well-formed XML and the parser is required to report this fact to the application.

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

Sidebar

Related Questions

I have found that writing PHP code within classes can become rather long: $this->parser->parse_syntax($this->get_language_path($this->language),
I have found some code that I need to use for my application but
I have found that my HTML is, to be honest, very clunky. Small, simple
I have found this code http://djangosnippets.org/snippets/2283/ but I think it doesn't work with manytomanyfields
I have found what I think is peculiar behavior in Android 3.x (Gingerbread) for
I have found code like this for dynamically creating a Grid and some columns:
Have found a function address in a DLL. Have no source code for this
I have found this code for a custom UITableViewCell : UITableViewCell *cell = [tableView
I have found the oddest behavior with my iOS app. I have this code:
I have found several websites pointing to using the following code to add support

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.