Qt-interest Archive, July 2007
CData dom question
Message 1 in thread
Hi,
I can't figure out how to read a CDATA section in an xml file.
Would someone know of an example on the net ?
TIA
Alain
--
[ signature omitted ]
Message 2 in thread
Hi,
denebet wrote:
> I can't figure out how to read a CDATA section in an xml file.
> Would someone know of an example on the net ?
The subject line mentions DOM, so I've attached a DOM example. Hope this
helps.
Tim
#include <QtXml>
#include <QtXml>
#include <QDebug>
#include <QString>
static QString DOC =
"<?xml version='1.0' encoding='ISO-8859-1'?>"
"<config>"
" <blah>"
" <![CDATA[blah1]]>"
" </blah>"
" <blah>"
" <![CDATA[blah2]]>"
" </blah>"
"</config>";
void printCDATA( QDomNode n )
{
if ( n.isCDATASection() )
qDebug() << n.toCDATASection().data();
QDomNode c = n.firstChild();
while ( !c.isNull() )
{
printCDATA( c );
c = c.nextSibling();
}
}
int main( int, char*[] )
{
QDomDocument doc;
doc.setContent( DOC );
printCDATA( doc.documentElement() );
return 0;
}
Message 3 in thread
Tim Dewhirst wrote:
> Hi,
>
> denebet wrote:
>> I can't figure out how to read a CDATA section in an xml file.
>> Would someone know of an example on the net ?
>
> The subject line mentions DOM, so I've attached a DOM example. Hope this
> helps.
Yes it does!
Thanks a lot.
Alain
--
[ signature omitted ]