Results 1 to 3 of 3

Thread: Convert QDomText to QString

  1. #1
    Join Date
    Nov 2013
    Qt products
    Qt4 Qt5

    Default Convert QDomText to QString

    I have a QDomDocument called doc and I need to make a QStringList of each of its top-level children. So far I have this:
    Qt Code:
    1. QDomNodeList nodes = doc.childNodes();
    2. for(int i = 0; i < nodes.size(); i++)
    3. {
    4. QDomText text =;
    5. //do something here...
    6. }
    To copy to clipboard, switch view to plain text mode 

    However, I cannot find any way to convert this to a QString. This is my first time ever working with The QDom* classes, so I'm pretty confused, and going by the docs there doesn't seem like much can be done with QDomText. Can anyone please offer some advice? Thanks in advance!

  2. #2
    Join Date
    Jan 2006
    Graz, Austria
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Unix/X11 Windows

    Default Re: Convert QDomText to QString

    It is not clear what you mean with "make a QStringList out of its top-level children".

    Can you post an XML example and the result you are expecting?


  3. #3
    Join Date
    Mar 2009
    Brisbane, Australia
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Unix/X11 Windows
    Wiki edits

    Default Re: Convert QDomText to QString

    QDomNode::nodeValue() on nodes of QDomNode::nodeType () == QDomNode::TextNode... The nodes you have selected will probably be type QDomNode::ElementNode with child nodes of text and possibly other stuff.

Similar Threads

  1. How convert Qt::Key to QString?
    By lenny in forum Qt Programming
    Replies: 3
    Last Post: 12th April 2012, 13:26
  2. convert Qstring into int
    By sabbu in forum Newbie
    Replies: 8
    Last Post: 8th June 2011, 17:31
  3. QStringList withing QDomText
    By NoRulez in forum Qt Programming
    Replies: 5
    Last Post: 13th November 2008, 11:13
  4. convert QString to int
    By mattia in forum Newbie
    Replies: 2
    Last Post: 4th January 2008, 10:10
  5. how to convert int to QString?
    By phillip_Qt in forum Newbie
    Replies: 2
    Last Post: 5th October 2007, 09:07

Tags for this Thread


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.