Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QXmlStreamWriter: How to create complex xml header ?

    General and Desktop
    2
    3
    3384
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Z
      Zaxy last edited by

      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 !

      1 Reply Last reply Reply Quote 0
      • Chris Kawa
        Chris Kawa Moderators last edited by

        @
        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();@

        1 Reply Last reply Reply Quote 0
        • Z
          Zaxy last edited by

          thank s lot

          1 Reply Last reply Reply Quote 0
          • First post
            Last post