PDA

View Full Version : How to display xml file in qwebview?



richardander
30th May 2009, 06:31
Hello,

In may application, I create a QWebView object.

It can display url, such as www.google.com. However, when I use it to open an xml. Nothing is shown.

I used the browser in QtDemo to load the xml file. It doesn't show, either.

Question: can Qt browser display xml file?

thank you!

kwisp
31st May 2009, 20:47
Question: can Qt browser display xml file?


QtWebKit provides facilities for rendering of HyperText Markup Language (HTML), Extensible HyperText Markup Language (XHTML) and Scalable Vector Graphics (SVG) documents, styled using Cascading Style Sheets (CSS) and scripted with JavaScript.


i think no.

Lykurg
31st May 2009, 21:10
It can display url, such as www.google.com. However, when I use it to open an xml. Nothing is shown.

I used the browser in QtDemo to load the xml file. It doesn't show, either.


And this is good, because it is handled as xml not as a text file! So <tag value="sdf" /> will show nothing.


Question: can Qt browser display xml file?
It displays it. Not the way you want, but...

Best thing would be you use a QTextEdit with a custom syntax highlighting. If not look through the sources where QWebView/page sets the html to the page, subclass that and if the file is xml replace all "<" and ">" with &lt; and &gt;. Also handle some other xml specific characters.