You do not want to do what the others have suggested. Use these routines for your DomElement, ect values.
(
const QString& encodeMe
)
{
for (quint32 index(0); index < encodeMe.size(); index++)
{
QChar character
(encodeMe.
at(index
));
switch (character.unicode())
{
case '&':
temp += "&"; break;
case '\'':
temp += "'"; break;
case '"':
temp += """; break;
case '<':
temp += "<"; break;
case '>':
temp += ">"; break;
default:
temp += character;
break;
}
}
return temp;
}
(
const QString& decodeMe
)
{
temp.replace("&", "&");
temp.replace("'", "'");
temp.replace(""", "\"");
temp.replace("<", "<");
temp.replace(">", ">");
return temp;
}
QString EncodeXML
(
const QString& encodeMe
)
{
QString temp;
for (quint32 index(0); index < encodeMe.size(); index++)
{
QChar character(encodeMe.at(index));
switch (character.unicode())
{
case '&':
temp += "&"; break;
case '\'':
temp += "'"; break;
case '"':
temp += """; break;
case '<':
temp += "<"; break;
case '>':
temp += ">"; break;
default:
temp += character;
break;
}
}
return temp;
}
QString DecodeXML
(
const QString& decodeMe
)
{
QString temp(decodeMe);
temp.replace("&", "&");
temp.replace("'", "'");
temp.replace(""", "\"");
temp.replace("<", "<");
temp.replace(">", ">");
return temp;
}
To copy to clipboard, switch view to plain text mode
If you use toPercentEncoding or...base64 encoding, who can read the xml that you have created? One of the benefits of XML is being able to read it from a text editor. Don't give up that advantage.
Bookmarks