Fixed startElement method in SyndHandler

This commit is contained in:
daniel oeh 2012-06-09 10:58:04 +02:00
parent 06688a139a
commit dc3ae95a89
2 changed files with 6 additions and 1 deletions

View File

@ -20,6 +20,7 @@ public class FeedHandler {
RSSHandler handler = new RSSHandler(feed); RSSHandler handler = new RSSHandler(feed);
try { try {
SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
SAXParser saxParser = factory.newSAXParser(); SAXParser saxParser = factory.newSAXParser();
saxParser.parse(new File(feed.getFile_url()), handler); saxParser.parse(new File(feed.getFile_url()), handler);
} catch (SAXException e) { } catch (SAXException e) {

View File

@ -25,7 +25,11 @@ public abstract class SyndHandler extends DefaultHandler{
state.tagstack.push(qName); state.tagstack.push(qName);
String[] parts = qName.split(":"); String[] parts = qName.split(":");
Namespace handler = state.namespaces.get(parts[0]); String prefix = "";
if (parts.length >= 2) {
prefix = parts[0];
}
Namespace handler = state.namespaces.get(prefix);
if (handler != null) { if (handler != null) {
handler.handleElement(localName, state, attributes); handler.handleElement(localName, state, attributes);
} }