Add "<?xml version="1.0" encoding="UTF-8" standalone="no" ?>" to the beginning of a QDomDocument?
-
wrote on 14 Apr 2011, 17:45 last edited by
I'm creating a QDomDocument like:
@
QDomImplementation impl;
QDomDocumentType dtd = impl.createDocumentType("name", "bla", "ble.dtd");
QDomDocument d = impl.createDocument(0, "name", dtd);
@After calling:
@d.save(output, 4);@my XML file does not have anything like @<?xml version="1.0" encoding="UTF-8" standalone="no" ?>@ on the beginning of it. How can I add it?
Thanks in advance
-
wrote on 14 Apr 2011, 20:40 last edited by
You can get text representation of your xml with toString(), concat it with needed xml declaration and save manually to file. AFAIK there is no builtin method for adding declaration.
-
wrote on 15 Apr 2011, 06:40 last edited by
To add the wanted line, just do :
@
QDomNode node( d.createProcessingInstruction( "xml", "version="1.0"",
"standalone="no"" ) );
d.insertBefore( node, d.firstChild() );
d.save(output, 4);
@ -
wrote on 15 Apr 2011, 10:05 last edited by
Closed thread. Same discussion as "here":http://developer.qt.nokia.com/forums/viewthread/5121/.
1/4