Yes, I have also encountered the same problem. Any suggestions?

On Nov 30, 10:53 pm, ChisterNordvik <[EMAIL PROTECTED]> wrote:
> Hi!
>
> Does anyone have a working RSS parser with Android? I tried doing
> simple DOM parsing of the XML but the character encoding isn't handled
> properly so the norwegian characters aren't displayed. I have tried
> everything but when I get the description element I just get the text
> until the norwegian character. Any sample code of parsing
> international RSS feeds would be very welcome!
>
> Here is the feed that I am having problems 
> with:http://www.dagbladet.no/rss/fotball/
>
> -Christer
>
> Sample code that I started out with (have tried lots of encoding
> tricks to no avail):
>
> Feed feed = createFeed(this,
>                                         new 
> java.net.URI("http://www.dagbladet.no/rss/fotball/";));
> ...
> public Feed createFeed(Context ctx, URI rssurl) {
>                 Feed feed = new Feed();
>                 try {
>                      DocumentBuilder builder =
>                        
> DocumentBuilderFactory.newInstance().newDocumentBuilder();
>                      Document doc = 
> builder.parse(rssurl.toURL().openStream());
>
>                      NodeList nodes = doc.getElementsByTagName("item");
>                      for (int i = 0; i < nodes.getLength(); i++) {
>                        Element element = (Element) nodes.item(i);
>
>                        NodeList title = element.getElementsByTagName("title");
>                        Element line = (Element) title.item(0);
>
>                        String feedTitle = getCharacterDataFromElement(line);
>                        String url = getCharacterDataFromElement
> (element.getElementsByTagName("link").item(0));
>                        Article art = new Article();
>                        art.title = feedTitle;
>                        art.url = url;
>                        art.description = getCharacterDataFromElement
> (element.getElementsByTagName("description").item(0));
>                        feed.articles.add(art);
>
>                      }
>                    }
>                    catch (Exception e) {
>                       e.printStackTrace();
>                    }
>                    return feed;
>         }
>         public static String getCharacterDataFromElement(Node e) {
>                    Node child = e.getFirstChild();
>                    if(child == null)
>                            return "?";
>                    if (child instanceof CharacterData) {
>                      CharacterData cd = (CharacterData) child;
>                        return cd.getData();
>                      }
>                    return "?";
>                  }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to