Same Problem Here. Post It In The Issue Tracker!

On 11/30/2008, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> 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 "?";
>>                  }
> >
>


-- 
Xavier A. Mathews
Student/Browser Specialist/Developer/Web-Master
Google Group Client Based Tech Support Specialist
Hazel Crest Illinois
[EMAIL PROTECTED]@[EMAIL PROTECTED]
"Fear of a name, only increases fear of the thing itself."

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
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