hi,
I am using this piece of code to validate an XML file against an XML scheam. Once the XML file is valide, I use QTextStream to read the file content as QString then display it on the terminal :
// open file
QFile file(filename);
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug() << "Cannot open file ";
return;
}
// validate file against XML schema
QXmlSchemaValidator validator(schema);
if(!validator.validate(&file, QUrl::fromLocalFile(file.fileName())))
{
file.close();
qDebug() << "instance document is invalid";
return;
}
//display
QTextStream textstream(&file);
QString xmlContent = textstream.readAll();
qDebug()<<xmlContent;
file.close();
But, the qDebug() function display an empty string (“”) !
Any idea ?
thanks in advance.
↧