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

Native Development

Reply
Developer
Posts: 358
Registered: ‎04-13-2013
My Device: Z10
My Carrier: Telus
Accepted Solution

HTML formatting issue

[ Edited ]

So I'm trying to create an app the pulls an RSS feed from my website and i've set the <content> into a label to show in a page but for some reason, sometimes the HTML coding is wonky and doesn't format properly, just showing code.

 

example:

IMG_20140412_125404.png

 

Other times it shows up perfectly:

IMG_20140412_125504.png

 

My code is this:

 

QString TLDRApp::findText(const QVariant item)
{
	QVariantMap itemData = item.toMap();
	QString description;
	        if (itemData.contains("content:encoded")) {
	            description = itemData["content:encoded"].toString();
	        }
	 return description;
}

 

Label {

id:contentLabel

text: <html>" + chosenItem.content + "</html>"

}

 What formatting can I add to ensure all the url links, paragraph breaks, bold/ italic letters and font size make it through and strip all the other formatting that may be causing the issue?

 

These are the only supported tags, so I was wondering if I could do a remove() and just focus on everything except for :

 

<a>
<b>
<br/>
<i>
<span>
<p>
<div>
<em>
<strong>

 

 

all help will be thanks and solutions marked.

 

thanks in advance, Brandon

Developer
Posts: 217
Registered: ‎09-18-2009
My Device: Z10
My Carrier: O2

Re: HTML formatting issue

Complete web sites are best displayed using a WebView.

 

https://developer.blackberry.com/native/reference/cascades/bb__cascades__webview.html

Developer
Posts: 358
Registered: ‎04-13-2013
My Device: Z10
My Carrier: Telus

Re: HTML formatting issue

as per the suggestion.  I used a webview and a custom CSS layout to display the information.  Works better and allows other stuff like Youtube videos and multiple images to be displayed.

 

Thanks!