QtXml and special characters
Hello,
I'm saving a QList of songs into an XML. That goes well but the loading doesn't work out very well :confused:
When I save for example the song "Björk - It's Oh So Quiet.mp3" you get this in the XML file:
<song title="It's Oh So Quiet" path="C:\Documents and Settings\Gillis\Mijn documenten\Mijn muziek\Apart\Björk - It's Oh So Quiet.mp3" artist="Björk" album="It's Oh So Quiet" id="66" />.
When I try to load the path or the artist the 'ö' changes in a '?' or other things...
This is how I load the attributes:
Code:
{
int id = element.attribute("id").toInt();
Song* song = new Song(id);
song->path = element.attribute("path");
song->info.title = element.attribute("title");
song->info.artist = element.attribute("artist");
song->info.album = element.attribute("album");
currentPlaylist->append(song);
}
I have tried using element.attribute("path").toAscii() but that doesn't work either...
Thanks in advance,
Gillis
Re: QtXml and special characters
What is the type of song->info.title? Does this XML contain information about encoding?
Re: QtXml and special characters
Quote:
Originally Posted by
jacek
What is the type of song->info.title? Does this XML contain information about encoding?
song->info.title is a QString and the XML hasn't got ecoding information...
Re: QtXml and special characters
How do you read the data into QDomDocument?
Re: QtXml and special characters
Quote:
Originally Posted by
jacek
How do you read the data into QDomDocument?
This is how I load it:
Code:
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;
}