An SO User
An SO User

Reputation: 24998

Configuring SAX parser

I am configuring the SAX parser to read the RSS feed. Here is how it looks:

public void processFeed(){
        try{
            SAXParserFactory factory = SAXParserFactory.newInstance();
            SAXParser parser = factory.newSAXParser();

            InputStream stream = new URL(url).openStream();

            XMLReader reader = parser.getXMLReader();
            reader.setContentHandler(this);

            reader.parse(new InputSource(stream));
        }catch(Exception e){
            errorOccured = true;
        }
    }  

The problem is that an error occurs and the boolean errorOccured is set to true. Can someone please tell me why this is generating an error ?

Upvotes: 1

Views: 112

Answers (1)

Miral Sarwar
Miral Sarwar

Reputation: 327

You have problem in this,

InputStream stream = new URL(url).openStream();

            XMLReader reader = parser.getXMLReader();
            reader.setContentHandler(this);

What's your url?

Upvotes: 2

Related Questions