Results 1 to 2 of 2

Thread: Help needed with QXmlQuery

  1. #1
    Join Date
    Apr 2008
    Posts
    196
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    1

    Default Help needed with QXmlQuery

    Hey @all,

    i want to make some steps with the QXmlQuery. Could anybody help me because in the Documentation of the QXmlQuery there aren't many examples.
    Qt Code:
    1. <document>
    2. <units name="Measures">
    3. <unit name="Meter">m</unit>
    4. <unit name="Centimeter">cm</unit>
    5. <unit name="Millimeter">mm</unit>
    6. </units>
    7. </document>
    To copy to clipboard, switch view to plain text mode 
    So, for the example normally i iterate over the nodes, but i think this is a good example where i can practice QXmlQuery. I want the units name, and then the unit names and there values.
    Currently I have the following to get the values of the units, but how can i get the attribute names and there values?
    Qt Code:
    1. QString filename = "test.xml";
    2.  
    3. QXmlQuery query;
    4.  
    5. QByteArray byteArray;
    6. QBuffer buffer(&byteArray);
    7. buffer.open(QIODevice::WriteOnly);
    8.  
    9. query.setQuery(QString("doc('%0')/document/units/unit/text()").arg(filename));
    10.  
    11. QXmlSerializer serializer(query, &buffer);
    12. bool ret = query.evaluateTo(&serializer);
    13.  
    14. QString source = QString(byteArray);
    15.  
    16. qDebug() << "XmlQuery Ret: " << ret;
    17. qDebug() << "XmlQuery Results: " << source;
    To copy to clipboard, switch view to plain text mode 
    I also noticed that xml query can be made with some sort of "SELECT * FROM ...", but how can I use them with QXmlQuery and I also don't know if there is a way to get a list of QDomNodes as results.

    Regards

  2. #2
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: Help needed with QXmlQuery

    I also don't know if there is a way to get a list of QDomNodes as results.
    Now you know: There isn't.

Similar Threads

  1. QXmlQuery / qof - gnucash book
    By tpf80 in forum Qt Programming
    Replies: 0
    Last Post: 29th October 2008, 20:22
  2. Possible to execute QXmlQuery on a QString?
    By chadkeck in forum Qt Programming
    Replies: 3
    Last Post: 8th October 2008, 17:24
  3. Problem with QXmlQuery and Visual Studio 2005
    By zorro68 in forum Qt Programming
    Replies: 4
    Last Post: 26th May 2008, 12:11
  4. Can't get QXmlQuery to return results
    By bpetty in forum Newbie
    Replies: 2
    Last Post: 13th May 2008, 14:27
  5. Forward declarations needed for some?
    By doktorn in forum Newbie
    Replies: 6
    Last Post: 28th November 2007, 08:56

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.