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. Add "<?xml version="1.0" encoding="UTF-8" standalone="no" ?>" to the beginning of a QDomDocument?

Add "<?xml version="1.0" encoding="UTF-8" standalone="no" ?>" to the beginning of a QDomDocument?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 4 Posters 10.9k 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.
  • J Offline
    J Offline
    jabtcha
    wrote on 14 Apr 2011, 17:45 last edited by
    #1

    I'm creating a QDomDocument like:

    @
    QDomImplementation impl;
    QDomDocumentType dtd = impl.createDocumentType("name", "bla", "ble.dtd");
    QDomDocument d = impl.createDocument(0, "name", dtd);
    @

    After calling:
    @d.save(output, 4);@

    my XML file does not have anything like @<?xml version="1.0" encoding="UTF-8" standalone="no" ?>@ on the beginning of it. How can I add it?

    Thanks in advance

    1 Reply Last reply
    1
    • D Offline
      D Offline
      DenisKormalev
      wrote on 14 Apr 2011, 20:40 last edited by
      #2

      You can get text representation of your xml with toString(), concat it with needed xml declaration and save manually to file. AFAIK there is no builtin method for adding declaration.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JohanSolo
        wrote on 15 Apr 2011, 06:40 last edited by
        #3

        To add the wanted line, just do :
        @
        QDomNode node( d.createProcessingInstruction( "xml", "version="1.0"",
        "standalone="no"" ) );
        d.insertBefore( node, d.firstChild() );
        d.save(output, 4);
        @

        `They did not know it was impossible, so they did it.'
        -- Mark Twain

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on 15 Apr 2011, 10:05 last edited by
          #4

          Closed thread. Same discussion as "here":http://developer.qt.nokia.com/forums/viewthread/5121/.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0

          1/4

          14 Apr 2011, 17:45

          • Login

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