Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
avinash_kumar_ispg_in
Posts: 172
Registered: ‎01-02-2012
My Device: 8520 curve

How to convert HTML strings into displayable styled text

Hi every one

 

I am getting the string which having some HTML tag like &amp,  and while I am adding it in to label field it is displaying all HTML content., so how to convert it into displayable text.

 

Can any body have idea

 

Thanks.

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to convert HTML strings into displayable styled text

Is this XML or HTML. 

 

If you are not seeing tags like <p> then I suspect you have XML data.  How did you get this data?  Normally you will get this from some XML parsing, in which case these characters will be replaced automatically.

Developer
avinash_kumar_ispg_in
Posts: 172
Registered: ‎01-02-2012
My Device: 8520 curve

Re: How to convert HTML strings into displayable styled text

Hi peter

 

 I am using json parsing not xml and my data is coming as a string like "Exceptional Ramadan at Jumeirah Hotels & Resorts" here & symbol is showing like &amp;.

 

What to do.

 

 

Thanks.

 

 

 

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to convert HTML strings into displayable styled text

This looks like XML encoding, not HTML encoding. 

 

Can you find out why the text data is being encoded in this way?  With JSON you don't need to encode the ampersand, but perhaps your Server is just using this encoding to make sure that the JSON string does not include a double quote.  Perhaps your Server is doing this, and the ampersand encoding is a side effect.  In which case you will need to 'undo' the encoding at the BlackBerry end.

Developer
avinash_kumar_ispg_in
Posts: 172
Registered: ‎01-02-2012
My Device: 8520 curve

Re: How to convert HTML strings into displayable styled text

Hi peter

thanks for response

 

but how to undo the encoding from blackberry end can you give little idea. As you know I am using json parsing so i am getting data as string.

 

Thanks.

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to convert HTML strings into displayable styled text

Can you confirm how the Server actually creates this data?  Why is it encoding the ampersands?