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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:57:57+00:00 2026-06-09T11:57:57+00:00

I’m working on an ANDROID app that reads RSS feeds so I used this

  • 0

I’m working on an ANDROID app that reads RSS feeds so I used this tutorial ( http://android-er.blogspot.com/2010/05/simple-rss-reader-ii-implement-with.html )/ source code available here, and implemented it to my own url rss feeder. But the description tag isn’t being shown..mostly cz in the xml of the feeder the description tags are CDATA.
how can i parse the description cdata in my rss??Thanks!

this is my handler code:

import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;

public class RSSHandler extends DefaultHandler {

final int state_unknown = 0;
final int state_title = 1;
final int state_description = 2;
final int state_link = 3;
final int state_pubdate = 4;
int currentState = state_unknown;

RSSFeed feed;
RSSItem item;

boolean itemFound = false;

RSSHandler(){
}

RSSFeed getFeed(){
    return feed;
}

@Override
public void startDocument() throws SAXException {
    // TODO Auto-generated method stub
    feed = new RSSFeed();
    item = new RSSItem();

}

@Override
public void endDocument() throws SAXException {
    // TODO Auto-generated method stub
}

@Override
public void startElement(String uri, String localName, String qName,
        Attributes attributes) throws SAXException {
    // TODO Auto-generated method stub

    if (localName.equalsIgnoreCase("item")){
        itemFound = true;
        item = new RSSItem();
        currentState = state_unknown;
    }
    else if (localName.equalsIgnoreCase("title")){
        currentState = state_title;
    }
    else if (localName.equalsIgnoreCase("description")){
        currentState = state_description;
    }
    else if (localName.equalsIgnoreCase("link")){
        currentState = state_link;
    }
    else if (localName.equalsIgnoreCase("pubdate")){
        currentState = state_pubdate;
    }
    else{
        currentState = state_unknown;
    }

}

@Override
public void endElement(String uri, String localName, String qName)
        throws SAXException {
    // TODO Auto-generated method stub
    if (localName.equalsIgnoreCase("item")){
        feed.addItem(item);
    }
}

@Override
public void characters(char[] ch, int start, int length)
        throws SAXException {
    // TODO Auto-generated method stub

    String strCharacters = new String(ch,start,length);

    if (itemFound==true){
    // "item" tag found, it's item's parameter
        switch(currentState){
        case state_title:
            item.setTitle(strCharacters);
            break;
        case state_description:
            item.setDescription(strCharacters);
            break;
        case state_link:
            item.setLink(strCharacters);
            break;
        case state_pubdate:
            item.setPubdate(strCharacters);
            break;  
        default:
            break;
        }
    }
    else{
    // not "item" tag found, it's feed's parameter
        switch(currentState){
        case state_title:
            feed.setTitle(strCharacters);
            break;
        case state_description:
            feed.setDescription(strCharacters);
            break;
        case state_link:
            feed.setLink(strCharacters);
            break;
        case state_pubdate:
            feed.setPubdate(strCharacters);
            break;  
        default:
            break;
        }
    }

    currentState = state_unknown;
}


  }

RSSFeed :

 import java.util.List;
 import java.util.Vector;

 public class RSSFeed {
   private String title = null;
   private String description = null;
   private String link = null;
   private String pubdate = null;
   private List<RSSItem> itemList;

RSSFeed(){
    itemList = new Vector<RSSItem>(0);
}

void addItem(RSSItem item){
    itemList.add(item);
}

RSSItem getItem(int location){
    return itemList.get(location);
}

List<RSSItem> getList(){
    return itemList;
}

void setTitle(String value)
{
    title = value;
}
void setDescription(String value)
{
    description = value;
}
void setLink(String value)
{
    link = value;
}
void setPubdate(String value)
{
    pubdate = value;
}

String getTitle()
{
    return title;
}
String getDescription()
{
    return description;
}
String getLink()
{
    return link;
}
String getPubdate()
{
    return pubdate;
}

   }
  • 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-09T11:57:58+00:00Added an answer on June 9, 2026 at 11:57 am

    That’s how I did:

    public class RssHandler extends DefaultHandler {
    
    private RssItem item;
    private RssFeed feed;
    private boolean inItem;
    
    private String value;
    private StringBuffer buffer;
    
    @Override
    public void startElement(
            String nameSpaceURI,
            String localName,
            String qName,
            Attributes atts
    ) {
    
        buffer = new StringBuffer();
    
        if (localName.equals("channel")) {
            feed = new RssFeed();
            inItem = false;
        } else if (localName.equals("item")) {
            item = new RssItem();
            inItem = true;
        }
    }
    
    public void endElement(
            String uri,
            String localName,
            String qName) {
    
        value = buffer.toString();
        buffer.setLength(0);
    
        value = Html.fromHtml(value).toString();
    
        if (localName.equals("pubDate") && !inItem) {
            feed.setPublishedDate(value);
        } else if (localName.equals("title") && !inItem) {
            feed.setTitle(value);
        } else if (localName.equals("link") && !inItem) {
            URL url = null;
            try {
                url = new URL(value);
            } catch (MalformedURLException e) {
                Log.e("ERR", "error while creating url from [" + value + "]");
            }
            if (url != null) {
                feed.setLink(url);
            }
        } else if (localName.equals("description") && !inItem) {
            feed.setDescription(value);
        } else if (localName.equals("pubDate") && inItem) {
            item.setPublishedDate(value);
        } else if (localName.equals("title") && inItem) {
            item.setTitle(value);
        } else if (localName.equals("link") && inItem) {
            URL url = null;
            try {
                url = new URL(value);
            } catch (MalformedURLException e) {
                Log.e("ERR", "error while creating url from [" + value + "]");
            }
            if (url != null) {
                item.setLink(url);
            }
        } else if (localName.equals("description") && inItem) {
            item.setDescription(value);
        } else if (localName.equals("item")) {
            feed.addItem(item);
            inItem = false;
        }
    }
    
    public void characters(char[] ch, int start, int end) {
        buffer.append(new String(ch, start, end));
    }
    
    public ArrayList<RssItem> getRss() {
        return this.rss;
    }
    }
    

    Hope this help. : )

    EDIT:

    I’ve edited my answer to match with your feed. Should work.
    Don’t forget to accept the answer if everythings is ok. 😉

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I know there's a lot of other questions out there that deal with this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small

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.