PDA

View Full Version : QXmlStreamReader - read a sub document



elcuco
22nd May 2010, 18:15
I am using QXmlStreamReader to parse this kind of XML:


<xml>
<param>
<name>age</name>
<type>int</type>
<value>42</value>
</param>

<param>
<name>name</name>
<type>string</type>
<value>dr blabla</value>
</param>

<param>
<name>data</name>
<type>xml</type>
<value>
<age>12</age>
<hieght>1.78 meters</height>
<age>12</age>
</value>
</param>
</xml>


What I need to do, is to get the whole 3rd param into a QString (or an QXmlDocument or something, not sure what is the best approach here). The problem with QXmlStreamReader is that I don't see a way to "skip" the content of this tag/node and get it as a verbatim text or something.

What do you suggest?

jryannel
23rd May 2010, 06:04
Try http://doc.qt.nokia.com/4.7-snapshot/qxmlstreamreader.html#readElementText, this should be able to read until the closing tag is found and returns it as a QString.

elcuco
23rd May 2010, 15:00
jryannel,

This returns the text inside the tags, not the "tags". In this example it will return "\n\t". Not what I am looking for.

wysota
23rd May 2010, 15:44
You need to pass it the QXmlStreamReader::IncludeChildElements parameter.