Escape html elements in blackberry
I was wondering if there is something for blackberry to escape html values, basically I want to show just plain text that's coming from and rss. However the rss is returning values likes this:
<item><guid isPermaLink="true"><![CDATA[http://www4.elcomercio.com/deportes
/Vettel_F1_China.aspx]]>
</guid>
<title><![CDATA[ Vettel domina primer día de ensayos en China]]></title>
<description><![CDATA[El alemán Sebastian Vettel, de Red Bull, realizó el mejor tiempo en la segunda sesión de entrenamientos libres del Gran Premio de China de Fórmula 1, el viernes en el circuito de Shanghai, tercera prueba del campeonato, tras haber dominado开发者_StackOverflow el primer ensayo.<br />
<br />
I can sucesffuly retrieve the title and description tags content, but now I would like to remove all the CDATA, <br />
or any possible html tags that I could find.
I tried using JSoup however it uses JVM 1.5+ classes like Enum, and as result I couldn't preverify the jar to use it on Blackberry-JavaME. Also I haven't found any class in the RIM API that could help on this task, maybe I missed a class or a library that I could use. This is just to avoid writing code that's probably already done on several libraries.
Thanks a lot.
Have you tried using SAX Parser and just getting the values for the characters(...) method for each endElement ?
Here is a brief tutorial on SAX Parser for Blackberry:
http://jsinghfoss.wordpress.com/2009/09/06/sax-parsing-revising/
Well, couldn't find a prerolled class, however there is a library that allows us to use regex in Blackberry projects, it's called regexp-me. Helped me to remove the tags in an easy way. SAX Parser is also a solution, but if you want something more simple like in this case, I think regexp-me is the best option. Thanks.
精彩评论