QDomDocument formatting
-
Hello. I am having some problems with creating a QDomDocument. I have the following code:
@QDomDocument dom;
QDomElement root = dom.createElement("cmd");
dom.appendChild(root);
QDomElement param = dom.createElement("param");
root.appendChild(param);
QDomElement id = dom.createElement("id");
QDomElement value = dom.createElement("value");
param.appendChild(id);
param.appendChild(value);
QDomText idTxt = dom.createTextNode("FOO");
id.appendChild(idTxt);
QDomText valueTxt = dom.createTextNode("BAR");
value.appendChild(valueTxt);@
It creates the following output:
@<cmd>
<param>
<id>FOO</id>
<value>BAR</value>
</param>
</cmd>
@
The issue I'm having, is that I"m not able to output a particular DOM element and it's associated children on the same line of the XML. Formatting like this is something that I think would be trivial, but I can't seem to make it happen and I don't see any examples demonstrating such an output. Does anybody know if this is possible using the QDom classes? I'm sure I can brute force it by manually generating the XML, but I would of course prefer to do it with the DOM classes. Any help would be greatly appreciated.
@<cmd>
<param><id>FOO</id><value>BAR</value></param>
</cmd>
@ -
I don't think that formatting at this level is supported.
-
No, it is not supported to be output the way you suggested.