PDA

View Full Version : QDomDocument or QXmlStreamReader



Poonarge
14th July 2014, 09:58
I've got an XML response, and I'm wondering which method is best to use to obtain the required information I need. I want to run through the XML, looking for specific elements and checking the text within.
Current code:



QXmlStreamReader sr(response);

while (!sr.atEnd())
{
sr.readNext();

if(sr.name() == "FeedSubmissionId")
{
QByteArray FeedSubmissionID = sr.readElementText().toUtf8();
GetFeedSubmissionList(FeedSubmissionID);
}
}
if (sr.hasError())
{
QString err = sr.errorString();
qDebug() << err;
}



Any advice would be much appreciated.

Regards,

Richard

anda_skoa
14th July 2014, 10:37
If you are only interested in certain parts then I'd say QXmlStreamReader.
It lets you skip whatever you are not interested in.

QDomDocument needs to parse the whole XML document into an internal memory tree.

Cheers,
_

Poonarge
14th July 2014, 10:54
Ok, thanks, will do that