try this code
...
doc.appendChild(doc.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""));
root.setAttribute("OS", 3);
root.setAttribute("CMD", "03");
root.setAttribute("VER", 1.0);
QDomElement parameters
= doc.
createElement("parameters");
QDomElement parameter
= doc.
createElement("parameter");
parameter.setAttribute("MODNAME", "iCMDataCard");
parameter.setAttribute("MODVERS", "1.0.1.2");
parameters.appendChild(parameter);
root.appendChild(parameters);
doc.appendChild(root);
QFile file("settings.xml");
out << doc.toString();
}
...
...
QDomDocument doc;
doc.appendChild(doc.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""));
QDomElement root = doc.createElement("communication");
root.setAttribute("OS", 3);
root.setAttribute("CMD", "03");
root.setAttribute("VER", 1.0);
QDomElement parameters = doc.createElement("parameters");
QDomElement parameter = doc.createElement("parameter");
parameter.setAttribute("MODNAME", "iCMDataCard");
parameter.setAttribute("MODVERS", "1.0.1.2");
parameters.appendChild(parameter);
root.appendChild(parameters);
doc.appendChild(root);
QFile file("settings.xml");
if (file.open(QIODevice::WriteOnly)) {
QTextStream out(&file);
out << doc.toString();
}
...
To copy to clipboard, switch view to plain text mode
Bookmarks