PDA

View Full Version : Possible to execute QXmlQuery on a QString?



chadkeck
8th October 2008, 05:41
I am trying to figure out how to execute a QXmlQuery on data in a QString.

For example, say I want to get all of the <img> tags from a QTextEdit's toHtml() method using XQuery.

I figured using XQuery would be the least amount of code so I don't have to reinvent the parsing of the HTML that toHtml() returns.

So is there any way to get the QXmlQuery to operate on a QString instead of using XQuery's fn:doc() function on a file?

Thanks!

yuriry
8th October 2008, 09:47
This method is probably what you need:



void QXmlQuery::setQuery ( const QString & sourceCode, const QUrl & documentURI = QUrl() )

yuriry
8th October 2008, 18:11
Sorry for the confusion but setQuery alone is not enough. You also need to use bindVariable. Please check this example (http://doc.trolltech.com/4.4/qxmlquery.html#bindVariable-2), it shows how to bind in-memory data to a variable and write a query using a bound variable.

chadkeck
8th October 2008, 18:24
Ahhh I see now.

It basically has an example of exactly what I want in the QXmlQuery::bindVariable() documentation.

Thanks