I am in middle of an Android project where I have to parse international language RSS (title and description is in another language) using SAX. When parsing, I get the following warning in Logcat. Also, none of the items in the RSS is parsed.
**9-10 07:12:33.598: W/System.err(1238): org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 3921: undefined entity**
09-10 07:12:33.598: W/System.err(1238): at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:520)
09-10 07:12:33.598: W/System.err(1238): at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:479)
09-10 07:12:33.598: W/System.err(1238): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:318)
09-10 07:12:33.608: W/System.err(1238): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:275)
09-10 07:12:33.608: W/System.err(1238): at com.example.news.FeedTableViewActivity$SAXHelper.parseContent(FeedTableViewActivity.java:255)
09-10 07:12:33.608: W/System.err(1238): at com.example.news.FeedTableViewActivity$ParseIndividualFeedTask.doInBackground(FeedTableViewActivity.java:217)
09-10 07:12:33.608: W/System.err(1238): at com.example.news.FeedTableViewActivity$ParseIndividualFeedTask.doInBackground(FeedTableViewActivity.java:1)
09-10 07:12:33.608: W/System.err(1238): at android.os.AsyncTask$2.call(AsyncTask.java:185)
09-10 07:12:33.608: W/System.err(1238): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
09-10 07:12:33.608: W/System.err(1238): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
09-10 07:12:33.608: W/System.err(1238): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
09-10 07:12:33.618: W/System.err(1238): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
09-10 07:12:33.618: W/System.err(1238): at java.lang.Thread.run(Thread.java:1019)
All other RSS feeds in English does not show any warning and hence its items are parsed.
A sample xml is here and here is my code portion:
public void parseUsingSAX(currentUrl){
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
xr.setContentHandler(df);
InputSource is = new InputSource(currentUrl.openStream());
is.setEncoding("UTF-8");
xr.parse(is);
}
Any help would be highly appreciated! Thanks!