Hello,
I am trying to take a QDomDocument and write to a .xml. I have got so far but now I can only produce empty documents.
doc.appendChild(root);
root.appendChild(tag);
QDomText t
= doc.
createTextNode("Hello World");
tag.appendChild(t);
cout << qPrintable(xml) << endl;
QFile file("something.xml");
{
TextStream << xml;
file.close();
}
return 0;
QDomDocument doc("MyML");
QDomElement root = doc.createElement("MyML");
doc.appendChild(root);
QDomElement tag = doc.createElement("greetings");
root.appendChild(tag);
QDomText t = doc.createTextNode("Hello World");
tag.appendChild(t);
QString xml = doc.toString();
cout << qPrintable(xml) << endl;
QFile file("something.xml");
if (!file.open(QIODevice::WriteOnly))
{
QTextStream TextStream(&file);
TextStream << xml;
file.close();
}
return 0;
To copy to clipboard, switch view to plain text mode
and this produces
<!DOCTYPE MyML>
<MyML>
<greetings>Hello World</greetings>
</MyML>
<!DOCTYPE MyML>
<MyML>
<greetings>Hello World</greetings>
</MyML>
To copy to clipboard, switch view to plain text mode
any help would be much appreciated,
Thanks,
a.
Bookmarks