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
Highlighted
Developer
Posts: 43
Registered: ‎07-23-2013
My Device: Z10
My Carrier: Vodacom

Text from RSS description field contains unwanted tags

I have an app which reads RSS feeds and depending on which feed service it is, the html tags appearing in front of or in between the 'description' field text of the RSS item.

 

It shows something like this for example (unwanted tags in red)..  "<!--PSTYLE=WL Web Lead--><p>Arts and <em>culture minister</em> is expected to launch..." yet there are some feeds where the description text appears absolutely fine.

 

Code as follows:

 

            ListView {
                id: myListView

                // Associate the list view with the data model that's defined in the
                // attachedObjects list
                dataModel: dataModellist
                layout: StackListLayout {
                }
                listItemComponents: [
                    ListItemComponent {
                        id: header
                        type: "header" //"item"

                        //custom components used instead of standardlistitem
                        Container {
                            Label {
                                id: emptytextheader
                                text: ""
                            }
                        }
                    },
                    ListItemComponent {
                        id: item
                        type: "item" //"description"

                        Container {
                            layout: DockLayout {
                            }
                            //custom components used instead of standardlistitem

                            Container {
                                id: itemdetails
                                Label {
                                    id: title
                                    text: ListItemData.title
                                    //textStyle.fontWeight: FontWeight.Bold
                                    multiline: true
                                    textStyle.color: Color.Cyan
                                }
                                Label {
                                    id: pubdate
                                    text: ListItemData.pubDate
                                    textStyle.color: Color.create("#ff00c200")
                                    textStyle.fontSize: FontSize.XSmall
                                }
                                Label {
                                    id: description
                                    text: ListItemData.description
                                    textStyle.fontSize: FontSize.Small
                                    multiline: true
                                    textStyle.color: Color.Yellow
                                    maxHeight: 130.0
                                }
                                //Divider {
                                //}
                            }
                        }

                    }
                ]

                onTriggered: {
                    var feedItem = dataModel.data(indexPath);
                    var page = detailsPage.createObject();
                    page.htmlContent = feedItem.link;
                    newsPane.push(page);
                }

                attachedObjects: [
                    ComponentDefinition {
                        id: detailsPage
                        source: "detailspage.qml"
                    }

                ]
                visible: false
            }

 

Developer
Posts: 43
Registered: ‎07-23-2013
My Device: Z10
My Carrier: Vodacom

Re: Text from RSS description field contains unwanted tags

Anybody? Know how to do a qml procedure to clean up text by removing certain characters like </> in a text field? Is it as much as doing it in C++?

Retired
Posts: 252
Registered: ‎08-17-2012
My Device: BlackBerry Z10 and Q10
My Carrier: Bell

Re: Text from RSS description field contains unwanted tags

Hi marioi, you will have to peform this operation in C++. Checkout the tldr sample app: https://github.com/blackberry/Cascades-Samples/blob/master/tldr/src/tldrapp.cpp. The tldrapp class has a plaintext() function which does what you are looking to do.

@SamarAbdelsayed

Did this answer your question? Please accept post as solution.
Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker