Results 1 to 4 of 4

Thread: Possible to execute QXmlQuery on a QString?

  1. #1
    Join Date
    Jul 2008
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default 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!

  2. #2
    Join Date
    Sep 2008
    Posts
    60
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Possible to execute QXmlQuery on a QString?

    This method is probably what you need:

    Qt Code:
    1. void QXmlQuery::setQuery ( const QString & sourceCode, const QUrl & documentURI = QUrl() )
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Sep 2008
    Posts
    60
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

  4. #4
    Join Date
    Jul 2008
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default 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

Similar Threads

  1. Custom Model Advice Requested
    By mclark in forum Qt Programming
    Replies: 3
    Last Post: 18th September 2008, 17:26
  2. easiest Way QString can do
    By baray98 in forum Qt Programming
    Replies: 12
    Last Post: 15th April 2008, 21:49
  3. QString static callback function from CURL
    By tpf80 in forum Qt Programming
    Replies: 12
    Last Post: 16th May 2007, 21:47
  4. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 18:59
  5. Converting QString to unsigned char
    By salston in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 23:10

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.