PDA

View Full Version : Convert QDomText to QString



thnkwthprtls
26th November 2013, 18:22
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:

QDomNodeList nodes = doc.childNodes();
for(int i = 0; i < nodes.size(); i++)
{
QDomText text = nodes.at(i).toText();
//do something here...
}


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!

anda_skoa
26th November 2013, 21:31
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,
_

ChrisW67
29th November 2013, 06:03
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.