Android :: SAXParser Fails On Some RSS Feeds

Feb 28, 2009

I'm using the SAX parser to read some RSS feeds and have found a problem. Some feeds, for example CNN Money Top Stories, have embedded some characters in their content, i.e. the copyright symbol. Well, that's not valid XML and the SAX Parser fails with an exception "invalid token". The only help I have seen given is to fix the XML at the source and that's not an option obviously. So, I can think of 2 options and they both stink:

(a) read the content first, scrub it, and then pass it to the parser.
(b) Use DOM instead of SAX.

What I *want* to do is make the parser a little more forgiving and just accept or discard/ignore the bad text. I'm not have any luck with setErrorHandler. My error handler does not get called.

Android :: SAXParser fails on Some RSS feeds


Android :: SAXParser With POST To URL

Jan 22, 2009

I have an API. I'm using that requires me to POST instead of use GET to submit my credentials before receiving back my XML response. I've parsed a bunch of various XML services like this, but this is the first time I've run across having to post to the URL. Basically they want a username and password parameter submitted as a post to the URL before the XML is fed back. Does anyone have a working example, or maybe able to point me in the right direction?

View 3 Replies View Related

Android :: How To Pause SAXParser?

Aug 27, 2010

I'm using SAXParser to parse large xml document from the net. And sometimes I need to pause SAXParser. I know how to stop parser by using SAXException, but how I can paused it? May be can I stop parser and then set up it to pass already parsed tags?

View 2 Replies View Related

Android :: SAXParser And Malformed XML

Aug 14, 2010

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!

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.
} }

View 2 Replies View Related

Android :: Youtube API - SAXParser Error

Jul 22, 2010

I have been trying to use the youtube APIs on the Android Platform (version 1.6) and have been stuck with the SAXParser whenever I send out a query from the following line of code:
VideoFeed videoFeed = service.query(query, VideoFeed.class);

I initially had errors with the SAXParser for which I applied the patch suggested here:
https://code.google.com/p/android/issues/detail?id=9493

After this, the previous error that I had which called an ExternalParametersEntities exception was resolved but I now get a Verify Error:
com.google.gdata.util.common.xml.parsing.SecureGenericXMLFactory $SecureSAXParserFactory

Would anyone know how to get around this error? Is there any other way to use the youtube API query on an Android platform?

View 3 Replies View Related

Android :: SAXParser Getting Stuck On Certain Characters

Jan 26, 2009

I'm using a SAXParser to parse an XML document and its getting stuck on certain symbols like the 'trademark' symbol and I think even double- quotes". I really don't need these characters so it would be fine if the parser just skips over these. Instead it throws an exception and quits parsing the document. What can I do?

View 7 Replies View Related

Android :: Using SAXParser To Get List Of Strings To Arraylist

Jun 21, 2010

I'm trying to parse a web service response using SAXParser and get certain values, store them into an arraylist, then display them in a listview. Example XML being returned from web service:
<ArrayOfStrings>
<string>value</string>
<string>value</string>
<string>value</string>
</ArrayOfStrings>

Here is my SAXHandler class:
public class SAXHandler extends DefaultHandler {
private boolean outertag = false;
private boolean mytag = false;
ArrayList<String> alist;
public ArrayList<String> getList(){
return this.alist;
} @Override
public void startDocument() throws SAXException {
} @Override
public void endDocument() throws SAXException{
} //@Override
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
if (localName.equals("ArrayOfString")){ this.outertag=true;
}else if (localName.equals("string")){ this.mytag=true;
} }
@Override
public void characters(char ch[], int start, int length) {
if (this.mytag){ String s = new String(ch, start, length);
alist.add(s);
} }
@Override public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
if (localName.equals("ArrayOfString")){ this.outertag=false;
}else if (localName.equals("string")){ this.mytag=false;
} } }

And here's my method calling and returing my web service:
try{ URL url = new URL("xxxxxxx");
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
SAXHandler SAXHandler = new SAXHandler();
xr.setContentHandler(SAXHandler);
xr.parse(new InputSource(url.openStream()));
ArrayList<String> stateList = SAXHandler.getList();
aa = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, stateList);
RESTlist.setAdapter(aa);
I keep getting an exception and I don't know why. Can anyone give me a hand?

Logcat:
06-21 20:10:47.901: ERROR/AndroidRuntime(472): Uncaught handler: thread main exiting due to uncaught exception
06-21 20:10:47.950: ERROR/AndroidRuntime(472): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.pa.passammain/com.pa.passammain.RESTtest}: java.lang.NullPointerException: println needs a message
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.os.Handler.dispatchMessage(Handler.java:99)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.os.Looper.loop(Looper.java:123)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.app.ActivityThread.main(ActivityThread.java:4203)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at java.lang.reflect.Method.invokeNative(Native Method)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at java.lang.reflect.Method.invoke(Method.java:521)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at dalvik.system.NativeStart.main(Native Method)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): Caused by: java.lang.NullPointerException: println needs a message
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.util.Log.println(Native Method)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.util.Log.e(Log.java:208)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at com.pa.passammain.RESTtest.onCreate(RESTtest.java:82)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
06-21 20:10:47.950: ERROR/AndroidRuntime(472): ... 11 more

After editing how my error is displayed in my try/catch i'm not longer getting an exception, but just a blank screen. Here is what my logcat is displaying:

06-21 20:22:00.330: WARN/System.err(542): java.lang.NullPointerException
06-21 20:22:00.352: WARN/System.err(542): at com.pa.passammain.SAXHandler.characters(SAXHandler.java:45)
06-21 20:22:00.352: WARN/System.err(542): at org.apache.harmony.xml.ExpatParser.text(ExpatParser.java:166)
06-21 20:22:00.362: WARN/System.err(542): at org.apache.harmony.xml.ExpatParser.append(Native Method)
06-21 20:22:00.371: WARN/System.err(542): at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:506)
06-21 20:22:00.371: WARN/System.err(542): at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:467)
06-21 20:22:00.371: WARN/System.err(542): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:329)
06-21 20:22:00.381: WARN/System.err(542): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:286)
06-21 20:22:00.381: WARN/System.err(542): at com.pa.passammain.RESTtest.onCreate(RESTtest.java:71)
06-21 20:22:00.391: WARN/System.err(542): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
06-21 20:22:00.391: WARN/System.err(542): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
06-21 20:22:00.401: WARN/System.err(542): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
06-21 20:22:00.401: WARN/System.err(542): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
06-21 20:22:00.410: WARN/System.err(542): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
06-21 20:22:00.410: WARN/System.err(542): at android.os.Handler.dispatchMessage(Handler.java:99)
06-21 20:22:00.420: WARN/System.err(542): at android.os.Looper.loop(Looper.java:123)
06-21 20:22:00.420: WARN/System.err(542): at android.app.ActivityThread.main(ActivityThread.java:4203)
06-21 20:22:00.420: WARN/System.err(542): at java.lang.reflect.Method.invokeNative(Native Method)
06-21 20:22:00.430: WARN/System.err(542): at java.lang.reflect.Method.invoke(Method.java:521)
06-21 20:22:00.430: WARN/System.err(542): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
06-21 20:22:00.442: WARN/System.err(542): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
06-21 20:22:00.442: WARN/System.err(542): at dalvik.system.NativeStart.main(Native Method)

View 1 Replies View Related

Android :: SAXParser Invalid Token Exception And Attribute Value

Jan 1, 2010

I am using SAXParser to parse an html page (any better solution?) and have this exception:
W/System.err( 1358): org.apache.harmony.xml.ExpatParser $ParseException: At line 1, column 59: not well-formed (invalid token)
I have reduced the page to this:
<div id="submenu"><a href="/compte/console.pl? id=382730&idt=1cf6b94aa1a4cf84"></a></div>
And what causes the exception is the '&' inside the href attribute value.

Here is a minimalist test code:
DefaultHandler emptySaxHandler = new DefaultHandler() {};
String xmlstr = "<div id="submenu"><a href="/compte/console.pl?id=382730&idt=1cf6b94aa1a4cf84"></a></div>";
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
saxParser.parse(new ByteArrayInputStream(xmlstr.getBytes ()),emptySaxHandler);

Is this a normal behaviour or kind of bug? If normal, what should do to preprocess the string before parsing?

View 3 Replies View Related

Android :: How To Get Rss Feeds

Oct 29, 2010

i need to get the feeds and display it in android. Any clue?

View 3 Replies View Related

Android :: Hard To Build RSS Feeds App?

Mar 10, 2009

I would like to know how hard would it be to to build RSS feeds app but only specific ones. For example politics: Pull rss feeds news from politico.com, cnn.com, fox.com etc..... and than display on G1... I would love some info on that and if someone can build such thing. ...am interested.

View 10 Replies View Related

Android :: Processing RSS Feeds With Namespaces

Apr 23, 2010

I'm trying to write an XML parser that takes an RSS feed & fetches the image urls shown in the url attribute of the <media:thumbnail> tag. This is all being done via android.Util.Xml, & is an adaptation of the code shown here. An example RSS feed that I'm trying to use is the BBC News RSS feed. However, media is an additional namespace & (probably) as a result my parser isn't working as it should. A version of my parse method is below. Is there any (no doubt simple) way to get my list of image URLs working?

..................

View 2 Replies View Related

Android :: Download RSS Feeds For Offline Use?

Mar 7, 2010

I use Newsrob, and curious as to what seems to be the most popular way to download RSS feeds for offline use? Do you download Articles / Articles + Images / Articles + Images + Mobile Web Page / Articles + Images + Web Pages?

View 6 Replies View Related

Android :: Deleting Default Feeds In Doggcatcher?

Aug 25, 2010

I just downloaded DoggCatcher podcast app. On startup, it had several default feeds like This American Life and This Week in Tech, etc.How do I delete those feeds from DoggCatcher?

View 1 Replies View Related

Sprint HTC Hero :: Podcasts - RSS Feeds And Android

Dec 30, 2009

So I am looking into Podcasts and RSS Feeds. I have used iTunes in the past to subscribe and watch podcasts, but havent been using iTunes much lately. RSS Feeds I am absolutely new to, and havent yet tried it out. From what I have read RSS Readers (like Google Reader) can subscribe to podcasts, but what about my phone? Would I need a separate RSS reader app, and would it sync with the subscriptions as my PC reader? Are there phone readers that support Video Podcasts?

The other option I saw was to use iTunes and tweak it to allow Podcasts to sync with your Android Device, but Im not sure if this method works with Videos. Im wondering which path is better and easier to manage? It seems easier to find and subscribe to videos using iTunes, but if there is another way, Im all for ditching iTunes completely. I am setting up Googe Reader for RSS feeds either way, I guess thats a separate issue, what I am mainly concerned with is syncing RSS feeds with my phone, and watching Video Podcasts on my Phone.

View 5 Replies View Related

Android :: Show Feeds From Blog In Listview

Jul 16, 2010

I want to show feeds from a blog in a listview.

View 1 Replies View Related

Android :: Parsing RSS 2.0 Feeds Using Pull Parser

May 13, 2010

I am trying to parse a RSS2.0 feed, obtained from a remote server, on my Android device using XML Pull Parser.

get a parser instance and set input,encoding
XmlPullParser parser = Xml.newPullParser();
parser.setInput(getInputStream(), null);

I am getting invalid token exceptions after a few items have been parsed:

Error parsing document. (position:line
-1, column -1) caused by: org.apache.harmony.xml.ExpatParser$ParseException:
At line 158, column 25: not
well-formed (invalid token)

Strangely, when I download the feed XML on the device, bundle it inside the raw folder and then run the same code. Everything works fine. What could be the problem here? How do I validate the XML before I parse it on device?

View 1 Replies View Related

Android :: Podcatcher That Works With Authenticated Feeds?

Jan 24, 2010

Essentially, I am looking for a podcatcher that will work with casts requiring authentication (HTTPS). I have several classes I would like to grab the feeds for, but require a login/password and none of the podcatchers I have tried work (Listen, DoggCatcher...etc). It doesn't have to be fancy, I just want something to listen to lectures on while on the fly and not have to worry about constantly syncing with a computer.

View 3 Replies View Related

Android :: No Feeds Appearing In Listen - How To Activate?

Aug 16, 2010

I have several subscribe-to podcast feeds in Google Reader. When hit 'refresh' in Listen, no feeds or podcasts ever appear. Is there a setting I need to change? I realize this is part of 'Labs', but seeing there are many who use this app, it must be something I'm overlooking.

View 2 Replies View Related

Android :: RSS Reader - Nice GUI And Default Feeds

Jun 8, 2010

What is the best RSS reader? I want to be able to read full stories off line after they've been downloaded. I've tried AP Mobile and Express News, they both have ugly GUI and rarely update - properly. Looking for a nice GUI and some default feeds.

View 12 Replies View Related

Android :: How To List Out Feeds From Face Book In Timeline Format

Jun 25, 2010

I have to do a small android application. It should connect with facebook and have to post feeds into wall and retrieve feeds to display in timeline format. I am new to android and fb. Could any one help?

View 1 Replies View Related

Android :: Using Android SAXParser - One My XML Elements Is Breaking In Half

Mar 30, 2010

Im using the SAXParser object do parse the actual XML.

This is normally done by passing a URL to the XMLReader.Parse method. Because my XML is coming from a POST request to a webservice, I am saving that result as a String and then employing StringReader / InputSource to feed this string back to the XMLReader.Parse method.

However, something strange is happening at the 2001st character of the XMLstring. The 'characters' method of the document handler is being called TWICE in between the startElement and endElement methods, effectively breaking my string (in this case a project title) into two pieces. Because I am instantiating objects in my characters method, I am getting two objects instead of one.

This line, about 2000 chars into the string fires 'characters' two times, breaking between "Lower" and "Level"

<title>SUMC-BOOKSTORE, LOWER LEVEL RENOVATIONS</title>

When I bypass the StringReader / InputSource workaround and feed a flat XML file to XMLReader.Parse, it works absolutely fine.

Something about StringReader and or InputSource is somehow screwing this up.

Here is my method that takes and XML string and parses is through the SAXParser.

CODE:.............

How to not have 'characters' firing off twice when I get to this point in the XML String.

Or, show me how to use a POST request and still pass off the URL to the Parse function.

View 3 Replies View Related

Android :: Implementing Characters Method Using SAXParser On Android?

Feb 8, 2010

I am parsing xml using the SAXParser and want to know if this is the right way to implement the characters method. Assume there's a class-level String variable named elementValue and it is initialized to "" in the startElement method.

Here is the characters method:
@Override
public void characters(char[] ch, int start, int length) {
String charsToAppend = new String(ch, start, length);
elementValue = elementValue + charsToAppend;
}
Is it correct that we need to append to the value we have so far and is the append being done correctly? Also, why does the characters method give the start index? Won't it be zero every time?

View 2 Replies View Related

Developed Application Not Displaying Feeds?

Aug 28, 2012

I have a question about an android application I developed, however, I need to do my introductory post first. So this is it.

View 1 Replies View Related

Android :: Cannot Read Two Different Tags Using SAXParser In Android?

Sep 23, 2010

I am using SAXParser to parse an XML document having three different tags. But in the result I get the value of only "one tag and not Other two tags. Can someone explain?
My XML is :
<outertag>
<innertag>hello</innertag>
<othertag>good morning</othertag>
<thirdtag Attribute="its a pleasant day"/>
</outertag>

View 1 Replies View Related

HTC Desire :: News Widget With 3 RSS Feeds - No Updating?

Oct 9, 2010

I have 3 RSS feeds attached to my news app. I have set the app to update every 2 hours. When I have the news widget up, it does not update at all. I have the click on the little update button. What can I do? I have powered off and on my phone etc. Is this common?

View 7 Replies View Related

HTC Desire :: Changing And Deleting News Feeds?

Sep 18, 2010

I am new to android and the desire, just upgraded from a nokia N96. I am running 2.2 android. A couple of questions regarding Rss feeds.

1. From the home screen, I can slide the screen to the left, twice and add a news feed. Can I add more than one feed here, and how can I change the one I have?
2. In "all apps > news" can I delete any of the pre installed news feeds?

View 2 Replies View Related

Samsung Captivate :: Feeds And Updates Showing Up Twice

Aug 26, 2010

I have Feeds and Updates showing up twice on one of the home screens. Is there a way to remove one of them?

View 2 Replies View Related

Samsung Captivate :: Bandwidth Usage / Feeds And Updates Widget

Sep 28, 2010

I am trying to track down a rogue application that seems to be receiving massive amounts of data. On the iPhone, I would use about 200mb/month due to WiFi at work and at home. However, on the Samsung Captivate, I can go from 100MB/month to 2+GB/month! I noticed huge amounts of data being used on my commutes to and from work.

On occasion, my home WiFi/DSL would get so lagged due to my Captivate being on the network that my son would complain and I would then put the phone in air plane mode. I reasoned that if it was happening on my WiFi network, as well as 3G, then perhaps I could using my router to log the activity to see what sites my phone was trying to connect to, then perhaps I could pinpoint the offending application.

My phone was connecting to a website that was part of a posting that was on facebook, which was only showing on the Samsung "Feeds and Updates" widget. I wasn't running the native facebook application at the time. I had the "Feeds and Updates" widget set to never update, unless I manually did it. Why was it trying to connect when it shouldn't have been? Don't know. Am I certain that this widget was the offending application? Not sure. Since removing the widget, I haven't had any bandwidth spikes.
PS. I tried Droid Wall, but it fails to work.

View 2 Replies View Related

Motorola Droid :: Live TV Feeds / Any Free Or Paid Sources?

Oct 18, 2010

I enjoy watching / listening to the CBS Early Show in the morning. Today it was not available through Miguntu Live TV or Channelsurfing.net. My question is, Are there other sources free or paid that you trust that can provide live TV that work?

View 3 Replies View Related

General :: Scrollable Widget Combining Facebook / Twitter / G+ And RSS Feeds?

Dec 17, 2011

A widget which puts all the posts from the "big ones" in one, scrollable feed? I want Facebook, Twitter, Google+ and various RSS feeds in one big feed on one of my home screens, preferably with customizable colours.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved