Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QXmlStreamWriter: How to create complex xml header ?

QXmlStreamWriter: How to create complex xml header ?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.6k Views
  • 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 Offline
    Z Offline
    Zaxy
    wrote on last edited by
    #1

    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
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @
      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
      0
      • Z Offline
        Z Offline
        Zaxy
        wrote on last edited by
        #3

        thank s lot

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved