PDA

View Full Version : Parse RSS into html and display it in QWebView.



halvors
14th August 2010, 01:56
Hi!

I need to make a simple function who parse the xml/rss feed and show it as HTML in QWebView.

Can anyone tell/help me how?

saa7_go
14th August 2010, 10:41
You can look at numbat's RSS Reader in this thread (http://www.qtcentre.org/threads/22973-RSS-Reader).

halvors
14th August 2010, 12:38
I ask how do it simple, and the rss reader you linked to does not work.

Can you please tell me how do it simple :)

halvors.

tbscope
14th August 2010, 12:50
I ask how do it simple
What is your definition of simple?
Do you understand that some things take effort? Me too, I want to have things for free and as fast as possible. Unfortunatly, this is not always possible.
Don't expect to find everything you need. Sometimes you need to create things yourself. This is what separates intelligent beings from lower lifeforms.

Suggestion:
Learn how to use google (or any other search engine)
Search for rss to html converters or libraries.
Learn how to include 3rd pary libraries into your program, or how to use processes
Learn the api of that library, or how to communicate with another process.

You see, only the sun shines for free. You do need to make a little bit of effort, especially when you ask for help.


and the rss reader you linked to does not work.
That might very well be, but hey, you have the source code. Use it to your advantage.

halvors
14th August 2010, 13:13
Seem like you dont understand my question, i need to get this exemple: http://doc.qt.nokia.com/4.6/xml-rsslisting.html to parse into webView, i ask how?

squidge
14th August 2010, 13:20
One way would be to take the output from rsslisting and generate a html page, then use webview to view that page.

tbscope
14th August 2010, 13:23
Seem like you dont understand my question, i need to get this exemple: http://doc.qt.nokia.com/4.6/xml-rsslisting.html to parse into webView, i ask how?

Sorry, you are right, I could not get that question from your previous posts.
Suggestion: next time ask exactly what you want please.

The Storm
14th August 2010, 13:23
Lol you are unbelievable! You have the source code and still you don't know how to display the HTML page that the XML is pointing to? I guess that you even haven't give a little effort to understand how the example works. Anyway here is my hint:

Take a look at the parseXml() method, you will see the line "if (xml.name() == "item")" that is adding items with the URL to the QTreeWidget, just use this URLs to put them in QWebView and make it load them. It is that simple...

Now I see that it is even easier, there is itemActivated(QTreeWidgetItem * item) slot that open the URL in external browser, you can add your code there to open it in QWebView.

halvors
14th August 2010, 13:24
Can you paste an simple exemple? I don't exactly know how...

The Storm
14th August 2010, 13:29
Are you sure you know how to program ? I really don't know how to put it simple, but here's your example:



void RSSListing::itemActivated(QTreeWidgetItem * item)
{
QWebView* webview = new QWebView( this );
webview->setWindowFlags( Qt::Window );
webview->load( QUrl(item->text(1)) );

//QDesktopServices::openUrl(QUrl(item->text(1)));
}


Now when you double click on item, it will open a QWebView window with the page you are looking for.

halvors
14th August 2010, 13:34
No im mean make it like firefox.

The Storm
14th August 2010, 13:44
Just wrap up the XML data in your custom HTML code, you can do that while parsing the RSS in parseXml(), and using some QString to put all the things togeder, then just grab that QString and show it in QWebView. Just add some check for the description too like:

if (currentTag == "description")

and voala, you have all the data you need, now you have to wrap it up in HTML tags. If you understand how to code HTML it should not be big deal.