[Qt-interest] xml parsing
Hasnat Raza
hasnatzaidi at gmail.com
Wed Oct 28 15:31:22 CET 2009
hi , I am trying to use xml in QT 4. I just create xml file which code is,
QDomDocument document;
QDomElement d= document.createElement("session");
d.setAttribute("name","sessiondetail");
QDomElement a = document.createElement( "title" );
a.setAttribute( "name", "SESSION_#_TITLE=" );
a.setNodeValue("Hasnat");
QDomText text = document.createTextNode( "title name" );
QDomElement b = document.createElement( "type" );
b.setAttribute( "name", "SESSION_#_TYPE =" );
QDomText text1 = document.createTextNode( "type name" );
document.appendChild( d );
d.appendChild( a );
a.appendChild( text );
d.appendChild( b );
b.appendChild( text1 );
qDebug() << a.text();
QFile file( "simple.xml" );
if( !file.open( QIODevice::WriteOnly | QIODevice::Text ) )
{
qDebug( "Failed to open file for writing." );
return;
}
QTextStream stream( &file );
stream << document.toString();
file.close();
and its output is...
<session name="sessiondetail" >
<title name="SESSION_#_TITLE=" >title name</title>
<type name="SESSION_#_TYPE =" >type name</type>
</session>
Now i Want to save these values in another file which name lets suppose
"prac.txt"
in as format like
SESSION_#_TITLE=title name
SESSION_#_TYPE=type name
Any one please guide the way....thanks in advance
regards,
raza
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091028/b7d3216e/attachment.html
More information about the Qt-interest-old
mailing list