DOMImplementationRegistry::getDOMImplementation on QtXML
-
Is there a direct mapping from the below implementation using Xerces on QtXML? Or for getting the DOM Implementation object I always need a QDomDocument instance?
@
DOMImplementation impl = DOMImplementationRegistry::getDOMImplementation(XMLString::transcode((const char)"Range"));
@thanks in advance!
-
Actually all I need is that my XML file has to have:
@<?xml version="1.0" encoding="UTF-8" standalone="no" ?>@
on the first line, even before:
@<!DOCTYPE System PUBLIC "-//blabla/bla" "b.dtd">@
for instance. I'm using QDomDocument::save() and the document never has what I need as a the first line so I thought that I was missing to get this implementation object from this "magical" registry that we don't have on QtXML. I'm clearly wrong about that, but how can I have this first line that I need now?
Thanks in advance
-
As I've said in another thread about xml declaration you simply can get text representation of your xml, concat with declaration and save manually to file.
-
This works for me:
@
QDomDocument doc("System PUBLIC "-//blabla/bla" "b.dtd"");
QDomProcessingInstruction pi = doc.createProcessingInstruction("xml", "version="1.0" encoding="UTF-8" standalone="no" ");
doc.appendChild(pi);QDomElement root = doc.createElement("System");
doc.appendChild(root);QDomElement tag = doc.createElement("Greeting");
root.appendChild(tag);QDomText t = doc.createTextNode("Hello World");
tag.appendChild(t);QString xml = doc.toString();
@ -
Volker, there is one problem in your code. XML declaration looks like processing instruction, but is not a processing instruction. Declaration can be only at the beginning of the file and instruction can be anywhere in file. So in your order of commands all will work ok, but only in this order (so your second command should always be second).