
Originally Posted by
jacek
How do you read the data into QDomDocument?
This is how I load it:
QFile device
("library.xml");
if(!device.
open(QFile::ReadOnly)) {
QMessageBox::warning(NULL,
"Library",
QString("Unable to load the library. Making a new one..."));
return false;
}
int errorLine;
int errorColumn;
if(!domDocument.setContent(&device, true, &errorStr, &errorLine, &errorColumn))
{
QMessageBox::information(NULL,
QString("Library"),
QString("Parse error at line %1, column %2:\n%3").
arg(errorLine
).
arg(errorColumn
).
arg(errorStr
));
return false;
}
QDomDocument domDocument;
QFile device("library.xml");
if(!device.open(QFile::ReadOnly))
{
QMessageBox::warning(NULL, "Library", QString("Unable to load the library. Making a new one..."));
return false;
}
QString errorStr;
int errorLine;
int errorColumn;
if(!domDocument.setContent(&device, true, &errorStr, &errorLine, &errorColumn))
{
QMessageBox::information(NULL, QString("Library"), QString("Parse error at line %1, column %2:\n%3").arg(errorLine).arg(errorColumn).arg(errorStr));
return false;
}
To copy to clipboard, switch view to plain text mode
Bookmarks