Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

xhr Rss Feed - Special Characters


From the KitchenSink project I used the xhr xml example. I have a RSS feed (including special danish characters æøå): http://snowboard.riders.dk/feed/ which Im trying to show in the android browser.

I have developed several native applications in xcode for the iPhone including feeds, so I have experience with this.

I have tried many methods to show the feed correctly, without succes.

  • convert feed (html entities)
  • custom html header in webview
  • looked at titanium webview documentation

How do I show special characters in the Android browser?

— asked September 2nd 2010 by Mads Møller
  • android
  • characters
  • encode
  • feed
  • mobile
  • special
  • xhr

3 Answers

  • No help?

    — answered September 14th 2010 by Mads Møller
    1 Comment
    • As an alternative approach, would it be possible to change the encoding of the Android browser?

      — commented September 16th 2010 by Mads Møller
  • Look this:


    I hope it work for you!

    — answered September 14th 2010 by Esteban Fernandez
    • I tried that, but I do not know how to use it with the xhr rss example…
      Your link example explains this:
      var doc = Ti.XML.parseString(encodeXMLString(this.responseText)).documentElement;

      but I have:
      var doc = this.responseXML.documentElement;
      var items = doc.getElementsByTagName("item");

      from here:

      Could you help me, how to do this?

      — commented September 14th 2010 by Mads Møller
    • Hi, I wrote that example in that page.
      You can get the response of the server both this way:
      var xml = this.responseXML;
      and this way:
      var xml = Ti.XML.parseString(this.responseText);
      The two are identical.

      So I only inserted the encodeXMLString function before the DOM parsing. After the doc=… code it is the same.

      — commented September 15th 2010 by Adam Wallner
    • Hi Adam
      I tried your approach, but does not work for me.
      this is my code: http://pastie.org/1163988 does it work in your end?

      — commented September 16th 2010 by Mads Møller
  • Hi, some time ago I posted a similar question here: http://developer.appcelerator.com/question/56091/xml-parser-unable-to-correctly-handle-numeric-entities-android.

    It seems that the xml parser in Titanium on Android is somewhat buggy.

    Here: http://gist.github.com/580493 you can find the code I'm using right now to overcome the problem.

    You can use the function in the following way:

    var xhr = Titanium.Network.createHTTPClient();
    xhr.onload = function(){
       var xmlStr = this.responseText;
       var xmlDoc = Ti.XML.parseString(mgDecodeHTMLEntities(xmlStr)));
       //perform usual processing

    I hope it will help!

    — answered September 15th 2010 by Olivier Morandi
    1 Comment
    • Thanks for the reply.. I guess your example works for decoding html.
      I need a "æ" to be "æ", so I need a encoder, right?

      — commented September 16th 2010 by Mads Møller
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.