I want to read the contents of a XML file. This in my code:
QDomDocument doc("mydocument");
QFile file("CHOIX_DE_LA_CATEGORIE.xml");
if (!file.open(QIODevice::ReadOnly))
return;
if (!doc.setContent(&file))
{
file.close();
return;
}
file.close();
QDomElement docElem = doc.documentElement();
QDomNode n = docElem.firstChildElement("ss:Worksheet");
if (!n.isNull() && n.isElement())
{
QDomElement e = n.toElement();
ui->listWidget->addItem(e.text());
}
When I execute the program, in then listWidget is added a single line with all the contents of my file!! All the file in a single line without space.
Why???
How can I read from the file the single elements, the single fields?
Bookmarks