PDA

View Full Version : How to read and get the values out of the xml?



dark1988
15th July 2008, 04:56
How to read and get the values out of the xml file and set text to the textfields?
:confused:

aamer4yu
15th July 2008, 06:34
Please search previous threads. This has been discussed recently.
One link is this (http://www.qtcentre.org/forum/f-qt-programming-2/t-xml-in-qt-14745.html)

dark1988
15th July 2008, 07:41
but they are creating and write on the xml file.. i need to noe how to read and get values out from the xml file and put into the textfield.

wysota
15th July 2008, 09:01
Use QDomDocument as suggested.

dark1988
15th July 2008, 09:23
How to use QDomDocument??
Can i have the sample?? to retrieve values from xml file...
thanks

yxmaomao
15th July 2008, 09:34
QDomElement domElement
if ( !domElement.isNull() )
{
QString elementName = domElement.tagName();
if ( elementName.compare( "position" ) == 0 )
{
// Convert to position
QPoint p0;
p0.setX( domElement.attribute( "x" ).toInt() );
p0.setY( domElement.attribute( "y" ).toInt() );

}
}

it is a simple example for read <position x="12",y="13"/> , good luck!

dark1988
15th July 2008, 09:41
thanks.. i will try..:)