Possible to execute QXmlQuery on a QString?
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!
Re: Possible to execute QXmlQuery on a QString?
This method is probably what you need:
Code:
void QXmlQuery
::setQuery ( const QString & sourceCode,
const QUrl & documentURI
= QUrl() )
Re: Possible to execute QXmlQuery on a QString?
Sorry for the confusion but setQuery alone is not enough. You also need to use bindVariable. Please check this example, it shows how to bind in-memory data to a variable and write a query using a bound variable.
Re: Possible to execute QXmlQuery on a QString?
Ahhh I see now.
It basically has an example of exactly what I want in the QXmlQuery::bindVariable() documentation.
Thanks