我正在配置SAX解析器以读取RSS源。以下是它的外观:
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;
}
}
问题是发生错误并且布尔errorOccured
设置为true。有人可以告诉我为什么会产生错误吗?
答案 0 :(得分:2)
你有问题,
InputStream stream = new URL(url).openStream();
XMLReader reader = parser.getXMLReader();
reader.setContentHandler(this);
你的网址是什么?