http://blog.exitae.es/rss
Código:
Sabéis algo que me pueda ayudar ? Gracias :D package es.brianapp.blogexitae.parser; import java.util.Date; import org.apache.http.impl.cookie.DateParseException; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.ext.LexicalHandler; import org.xml.sax.helpers.DefaultHandler; import es.brianapp.blogexitae.db.DatabaseMap; import es.brianapp.blogexitae.db.Provider; import android.content.ContentResolver; import android.content.ContentValues; import android.net.Uri; import android.util.Log; public class RssHandler extends DefaultHandler implements LexicalHandler{ private boolean in_item = false; private boolean in_title = false; private boolean in_pubdate = false; private boolean in_link = false; private boolean in_comments = false; private boolean in_dccreator = false; private boolean in_description = false; private boolean in_CDATA = false; private ContentResolver resolver; private ContentValues values; private Uri provider_uri = Provider.CONTENT_URI; @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { values = new ContentValues(); if (localName.equalsIgnoreCase("item")) { in_item = true; Log.d("Handler START TAG", localName); }else if (localName.equalsIgnoreCase("title")){ in_title = true; }else if (localName.equalsIgnoreCase("pubdate")){ in_pubdate = true; }else if (localName.equalsIgnoreCase("dc:creator")){ in_dccreator = true; }else if (localName.equalsIgnoreCase("link")){ in_link = true; }else if (localName.equalsIgnoreCase("description")){ in_description = true; }else if (localName.equalsIgnoreCase("comments")){ in_comments = true; } super.startElement(uri, localName, qName, attributes); } @Override public void endElement(String uri, String localName, String qName) throws SAXException { if (localName.equalsIgnoreCase("item")) { resolver.insert(provider_uri, values); Log.d("Handler END TAG", localName); in_item = false; }else if (localName.equalsIgnoreCase("title")){ in_title = false; }else if (localName.equalsIgnoreCase("pubdate")){ in_pubdate = false; }else if (localName.equalsIgnoreCase("dc:creator")){ in_dccreator = false; }else if (localName.equalsIgnoreCase("link")){ in_link = false; }else if (localName.equalsIgnoreCase("description")){ in_description = false; }else if (localName.equalsIgnoreCase("comments")){ in_comments = false; } super.endElement(uri, localName, qName); } @Override public void characters(char[] ch, int start, int lenght) throws SAXException { if(in_item){ if (in_title) { values.put(DatabaseMap.Posts.TITULO, new String(ch,start,lenght)); }else if (in_link){ values.put(DatabaseMap.Posts.LINK, new String(ch,start,lenght)); }else if (in_description){ values.put(DatabaseMap.Posts.DESCRIPCION, new String(ch,start,lenght)); }else if (in_pubdate){ String StringDate = new String(ch,start,lenght); try{ long date = Date.parse(StringDate); values.put(DatabaseMap.Posts.FECHA, date); }catch(Exception e){ // } } } super.characters(ch, start, lenght); } @Override public void comment(char[] ch, int start, int length) throws SAXException { // TODO Auto-generated method stub } @Override public void endCDATA() throws SAXException { in_CDATA = false; } @Override public void startCDATA() throws SAXException { in_CDATA = true; } @Override public void startDTD(String name, String publicId, String systemId) throws SAXException { // TODO Auto-generated method stub } @Override public void endDTD() throws SAXException { // TODO Auto-generated method stub } @Override public void startEntity(String name) throws SAXException { // TODO Auto-generated method stub } @Override public void endEntity(String name) throws SAXException { // TODO Auto-generated method stub } }