[Qt-interest] How to get xml file providing an URL and to parse that xml file

Frans Englich fenglich at trolltech.com
Wed Dec 10 08:46:20 CET 2008


On Wednesday 10 December 2008 05:46:37 Bijay Panda wrote:
> Hi All,
> I have a requirement like this.
> I have to provide an URL which will return  a XML file.
> then I've to parse that XML file and display data.
> Can i  make it  with Qt . getting xml file from a URL ( web call) can be
> done
> with cURL i know . but how can be  in Qt.
> My xml file will be of RSS 2.0 format.

On way is to use the QtXmlPatterns module, and write a small XQuery script. 
The XQuery script would maybe look like this:

declare namespace rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
<html>
	<body>
		{
			(: For each RDF description element, create a HTML paragraph and copy in
			   the description element's text. :)
			for $desc in doc("http://site.com/path/to/feed.rss")//rdf:description
			return <p>{string()}</p>
		}
	</body>
</html>

And then you would run the query and insert the result into a 
QWebView(Webkit). See examples/xmlpatterns/recipes/, and in assistant view 
the page named A Short Path to XQuery.



Cheers,

		Frans



More information about the Qt-interest-old mailing list