Hi, I am using a saxparser to read RSS XML from the web and populate
listviews. Everything works fine until I come across malformed XML,
usually encoding related, and my reader falls over.

I have changed it so that it gets as many items parsed and populated
before falling over (by default if it finds a malformed XML, then it
will give up and return an empty collection). The problem is, the next
time I try and view that feed (or any other feed), it still has the
contents after the malformed bit hanging around. For example, the
first time it now shows all the items upto the malformed item, if I
refresh, it will only show items after, refresh again, it will show
items upto and so forth.

The weird thing is, I create a new instances of everything every time.
So I don't understand why stuff is handing around.. It's like there is
some read pointer, or connection that needs to be closed and reset,
but I can't for the life of me work out what or where!

Any help would be gratefully appreciated. Thanks.

My GetFeed method:

 private RSSFeed getFeed(String urlToRssFeed)
   {
       SAXParserFactory factory;
       SAXParser parser;
       XMLReader xmlreader;
       URL url;
       InputSource is;
      try
      {
         url = new URL(urlToRssFeed);
         factory = SAXParserFactory.newInstance();
         factory.setValidating(false);
         parser = factory.newSAXParser();
         xmlreader = parser.getXMLReader();

         xmlreader.setContentHandler(m_FeedHandler);
         is = new InputSource(url.openStream());
         xmlreader.parse(is);
         m_ErrorCode = NOERROR;
      }
      catch (SAXParseException e)
      {
         e.printStackTrace();
         m_ErrorCode = XMLFORMAT;
      }
      catch (Exception e)
      {
         e.printStackTrace();
         m_ErrorCode = CONNECTION;
      }
      finally
      {
          is = null;
          url = null;
          parser = null;
          factory = null;
          return m_FeedHandler.getFeed();  //May be complete, partial
or empty.
      }
   }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to