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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:07:13+00:00 2026-05-14T23:07:13+00:00

I am trying to parse a Rss2.0 feed on Android using a Pull parser.

  • 0

I am trying to parse a Rss2.0 feed on Android using a Pull parser.

XmlPullParser parser = Xml.newPullParser();
parser.setInput(url.open(), null);

The prolog of the feed XML says the encoding is “utf-8”. When I open the remote stream and pass this to my Pull Parser, I get invalid token, document not well formed exceptions.

When I save the XML file and open it in the browser(FireFox) the browser reports presence of Unicode 0x12 character(grave accent?) in the file and fails to render the XML.

What is the best way to handle such cases assuming that I do not have any control over the XML being returned?

Thanks.

  • 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-14T23:07:13+00:00Added an answer on May 14, 2026 at 11:07 pm

    Where did you find that 0x12 is the grave accent? UTF-8 has the character range 0x00-0x7F encoded the same as ASCII, and ASCII code point 0x12 is a control character, DC2, or CTRL+R.

    It sounds like an encoding problem of some sort. The simplest way to resolve that is to look at the file you’ve saved in a hex editor. There are some things to check:

    1. the byte order mark (BOM) at the beginning might confuse some XML parsers
    2. even though the XML declaration says the encoding is in UTF-8, it may not actually have that encoding, and the file will be decoded incorrectly.
    3. not all unicode characters are legal in XML, which is why firefox refuses to render it. In particular, the XML spec says that that 0x9, 0xA and 0xD are the only valid characters less than 0x20, so 0x12 will definitely cause compliant parsers to grumble.

    If you can upload the file to pastebin or similar, I can help find the cause and suggest a resolution.

    EDIT: Ok, you can’t upload. That’s understandable.

    The XML you’re getting is corrupted somehow, and the ideal course of action is to contact the party responsible for producing it, to see if the problem can be resolved.

    One thing to check before doing that though – are you sure you are getting the data undisturbed? Some forms of communication (SMS) allow only 7-bit characters. This would turn 0x92 (ASCII forward tick/apostrophe – grave accent?) into 0x12. Seems like quite a coincidence, particularly if these appear in the file where you would expect an accent.

    Otherwise, you will have to try to make best do with what you have:

    1. although not strictly necessary, be defensive and pass “UTF-8” as the second paramter to setInput, on the parser.

    2. similarly, force the parser to use another character encoding by passing a different encoding as the second parameter. Encodings to try in addtion to “UTF-8” are “iso-8859-1” and “UTF-16”. A full list of supported encodings for java is given on the Sun site – you could try all of these. (I couldn’t find a definitive list of supported encodings for Android.)

    3. As a last resort, you can strip out invalid characters, e.g. remove all characters below 0x20 that are not whitespace (0x9,0xA and 0xD are all whitepsace.) If removing them is difficult, you can replace them instead.

    For example

    class ReplacingInputStream extends FilterInputStream
    {
       public int read() throws IOException
       {
          int read = super.read();
          if (read!=-1 && read<0x20 && !(read==0x9 || read==0xA || read==0xB))
             read = 0x20;
          return read;          
       }
    }
    

    You wrap this around your existing input stream, and it filters out the invalid characters. Note that you could easily do more damage to the XML, or end up with nonsense XML, but equally it may allow you to get out the data you need or to more easily see where the problems lie.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I set mine the old way and the new way,… May 15, 2026 at 4:38 pm
  • Editorial Team
    Editorial Team added an answer Since ASP.Net 2.0 doesn't render this appropriately (it's intended purpose… May 15, 2026 at 4:38 pm
  • Editorial Team
    Editorial Team added an answer Locking is not a function of rails, it is just… May 15, 2026 at 4:38 pm

Trending Tags

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

Top Members

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.