PDA

View Full Version : Pass xml file from javascript to qt using qwebkit bridge



linus11
21st February 2013, 16:12
Hi!

Have some problem with trying to pass a xml file as a domdocument from javascript to my c++ code in qt. Is there any way doing this?

The reason is that I need to parse a xml file using xslt using but I find it to time inefficient to first convert the xml document to a string and then send it to qt. Would be much bether if I can just send it directly. Or is there maybe any other approach doing this that would be bether? Also how good is the internal xslt transformation in qt compare to other libraries for example xalan? As I have understand it you have to use an external library to parse xml files with xslt to get a good result viewing webpages that is using this? Many questions I know but have been sitting with this for a while and would really appreciated any help I can get :)

wysota
21st February 2013, 23:03
Would be much bether if I can just send it directly.
Using what API?


Also how good is the internal xslt transformation in qt compare to other libraries for example xalan?
Xalan is more complete. WebKit should have its own XSL transformer though that should be complete (feature-wise).


As I have understand it you have to use an external library to parse xml files with xslt to get a good result viewing webpages that is using this?
I don't understand what you mean.

linus11
22nd February 2013, 11:18
Using what API?

I am pretty new to these things but and have only been programming in c++ before but any API that make it possible to pass a xml domdocument in a similar way to the way qwebelement can pass html domdocument from javascript to c++ would be great.



Xalan is more complete. WebKit should have its own XSL transformer though that should be complete (feature-wise).

Ok, thanks!



I don't understand what you mean.

Similar to the first question so sorry for this, just ignore it!

wysota
22nd February 2013, 12:25
I am pretty new to these things but and have only been programming in c++ before but any API that make it possible to pass a xml domdocument in a similar way to the way qwebelement can pass html domdocument from javascript to c++ would be great.
There is no common API between WebKit and QDomDocument. You can access the page DOM directly from C++ using QWebElement and family, if you want but you can't "convert" it to QDomDocument.

linus11
26th February 2013, 10:49
There is no common API between WebKit and QDomDocument. You can access the page DOM directly from C++ using QWebElement and family, if you want but you can't "convert" it to QDomDocument.

Is there any simple way to implement for webkit to be able to send new user defined types then from javascript to c++? QWebelement doesn't work for xml files as i understand it...

wysota
26th February 2013, 11:45
You can expose your own C++ API to WebKit.

linus11
6th March 2013, 14:25
You can expose your own C++ API to WebKit.

Can you explain or link any webpage that shows more exactly how to do that? Been looking for it myself but haven't been able to find anything...

wysota
6th March 2013, 16:09
http://qt-project.org/doc/qt-5.0/qtwebkit/qwebframe.html#addToJavaScriptWindowObject

and this in general:

http://qt-project.org/doc/qt-5.0/qtwebkit/qtwebkit-bridge.html