QXmlStreamWriter: How to create complex xml header ?
-
Hello,
I want to create the following complex xml header with QXmlStreamWriter:
@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="./AutoValidationRepport_HTML_Transformation.xsl" type="text/xsl" ?>
<AutomaticValidation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:./AutoValidationRepportSchema.xsd">
@To create the first line, I could call writeStartDocument(), but for the rest I cannot find any info how to create it ?
Could you please advise on this issue ?
Many thannks in advance !
-
@
QByteArray data;
QString namespaceUri = "http://www.w3.org/2001/XMLSchema-instance";QXmlStreamWriter w(&data);
w.setCodec("UTF-8"); //this is redundant, but that's how you set encoding
w.writeStartDocument();
w.writeProcessingInstruction("xml-stylesheet", "href="./AutoValidationRepport_HTML_Transformation.xsl" type="text/xsl"");w.writeStartElement("AutomaticValidation");
w.writeNamespace(namespaceUri, "xsi");
w.writeAttribute(namespaceUri, "noNamespaceSchemaLocation", "file:./AutoValidationRepportSchema.xsd");
...
w.writeEndElement();
w.writeEndDocument();@