0

I'm trying to fetch the content of website and making it to display in the android app, so i followed the tutorial which uses SAX parser to parse the XML content of the website, so according to the instruction I had created RSS HANDLER CLASS the functionality of that class is the SAX Parser traverses through the entire XML file and whenever it comes across an opening tag occurs then the endElement method gets called and the localname variable gets assigned with its name, I'm getting error in getTitle(), getthumb() etc., so please can anybody correct the mistake I had done.. here is my RSS Handler code.. enter code here class RSSHandler extends DefaultHandler {

private static final String PostList = null;
private Post currentPost = new Post();
StringBuffer chars = new StringBuffer();

@Override
public void startElement(String uri, String localName, String qName,
        Attributes atts) {

    chars = new StringBuffer();
    if (localName.equalsIgnoreCase("item")) {

    }
}

@Override
public void endElement(String uri, String localName, String qName)
        throws SAXException {

    if (localName.equalsIgnoreCase("title")
            && currentPost.getTitle() == null) {
        currentPost.setTitle(chars.toString());

    }
    if (localName.equalsIgnoreCase("pubDate")
            && currentPost.getPubDate() == null) {
        currentPost.setPubDate(chars.toString());

    }
    if (localName.equalsIgnoreCase("thumbnail")
            && currentPost.getThumbnail() == null) {
        currentPost.setThumbnail(chars.toString());

    }
    if (localName.equalsIgnoreCase("link")
            && currentPost.getUrl() == null) {
        currentPost.setUrl(chars.toString());
    }

    if (localName.equalsIgnoreCase("item")) {
        PostList.add(currentPost);
        currentPost = new Post();
    }
BenMorel
  • 34,448
  • 50
  • 182
  • 322
  • the error is, "The method getTitle() is undefined for the type Post", similarly for getPubDate(), getThumbnail().. – user1796350 Nov 08 '12 at 07:19

1 Answers1

0

I think that is your problem in your retrieval element . because you are get item or value form them but they response as null so it may be problem in their.

see This Example May be Guide you.

Chintan Khetiya
  • 15,962
  • 9
  • 47
  • 85