[SOLVED]QXmlStreamWrite writing namespace !
-
Hi,
I have to write an XML file using QXmlStreamWrite like this :@
<?xml version="1.0" encoding="UTF-8"?>
<pnml >
<net>
.....................
</net>
</pnml>
@But, QXmlStreamWriter assigns a prefix consisting of the letter 'n' followed by a number, by default :
@
<?xml version="1.0" encoding="UTF-8"?>
<pnml xmlns:n1="http://www.pnml.org/version-2009/grammar/pnml">
<net>
.....................
</net>
</pnml>
@Which is not allowed in my "XML scheam":http://www.pnml.org/version-2009/grammar/pnmlcoremodel.rng.
So after writing the XML file I have always to open that file and eliminate by hand the " :n1 " string. Which is not
practical !Is there any suggestion ?
thanks in advance.
-
Hi,
using
@void QXmlStreamWriter::writeNamespace(const QString & namespaceUri, const QString & prefix = QString())@you can specify your namespace prefix.
One question: you want only erase "n1" or all the namespace declaration?
Namespaces are used to avoid naming conflict, so you MUST provide prefix to identify them.
P.S. In the case you don't have naming conflict problems you can use
@
void QXmlStreamWriter::writeDefaultNamespace(const QString & namespaceUri)
@ -
thank you mcosta :)
the method :
@
void QXmlStreamWriter::writeDefaultNamespace(const QString & namespaceUri)
@is exactly what i meant! ;)