Results 1 to 3 of 3

Thread: Convert QDomText to QString

  1. #1
    Join Date
    Nov 2013
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    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 = nodes.at(i).toText();
    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
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    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?

    Cheers,
    _

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    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, 12:26
  2. convert Qstring into int
    By sabbu in forum Newbie
    Replies: 8
    Last Post: 8th June 2011, 16:31
  3. QStringList withing QDomText
    By NoRulez in forum Qt Programming
    Replies: 5
    Last Post: 13th November 2008, 10:13
  4. convert QString to int
    By mattia in forum Newbie
    Replies: 2
    Last Post: 4th January 2008, 09:10
  5. how to convert int to QString?
    By phillip_Qt in forum Newbie
    Replies: 2
    Last Post: 5th October 2007, 08:07

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.