Hi,
Below is my code & xml file. I am trying to read a xml file and store the contents. But its not working. Please help
int ParseConfigFile::populateUserValues ( string &OS, string &dir, string &logPath )
{
QFile file("config_v1.xml");
if ( doc.setContent( file.readAll() ) == false )
return 1;
element = doc.documentElement();
QDomElement firstChild
= list.
at(0).
toElement();
// will return the first child
s1 = firstChild.text();
s2 = secondChild.text();
s3 = thirdChild.text();
OS = s1.toStdString();
dir = s2.toStdString();
logPath = s3.toStdString();
return 0;
}
int ParseConfigFile::populateUserValues ( string &OS, string &dir, string &logPath )
{
QDomDocument doc;
QDomElement element;
QFile file("config_v1.xml");
if ( doc.setContent( file.readAll() ) == false )
return 1;
element = doc.documentElement();
QDomNodeList list = element.childNodes();
QDomElement firstChild = list.at(0).toElement(); // will return the first child
QDomElement secondChild = list.at(1).toElement();
QDomElement thirdChild = list.at(2).toElement();
QString s1,s2,s3;
s1 = firstChild.text();
s2 = secondChild.text();
s3 = thirdChild.text();
OS = s1.toStdString();
dir = s2.toStdString();
logPath = s3.toStdString();
return 0;
}
To copy to clipboard, switch view to plain text mode
Bookmarks