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. how to use QXmlStreamWriter ::writeCurrentToken

how to use QXmlStreamWriter ::writeCurrentToken

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 395 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.
  • O Offline
    O Offline
    Owen_cn
    wrote on last edited by
    #1

    when i read xml by QXmlStreamReader,and write by QXmlStreamWriter ::writeCurrentToken to a new file, the new file add "n1:" in each element,why?

    my code is like this

    QXmlStreamWriter *m_pWriter = new QXmlStreamWriter(&fileNew);
    m_pWriter->setAutoFormatting(true);
    m_pWriter->setCodec("ISO-8859-1");
    //
    while (!m_pReader->atEnd() && !m_pReader->hasError())
    {

        m_pReader->readNext();
        m_pWriter->writeCurrentToken(*m_pReader);
    }
    
    1 Reply Last reply
    0
    • kkoehneK Offline
      kkoehneK Offline
      kkoehne
      Moderators
      wrote on last edited by
      #2

      You don't say anything about the input XML, but this sounds like https://bugreports.qt.io/browse/QTBUG-75456 .

      Director R&D, The Qt Company

      JonBJ O 2 Replies Last reply
      2
      • kkoehneK kkoehne

        You don't say anything about the input XML, but this sounds like https://bugreports.qt.io/browse/QTBUG-75456 .

        JonBJ Online
        JonBJ Online
        JonB
        wrote on last edited by JonB
        #3

        @kkoehne
        Just so I understand: that bug is "critical" but "unresolved" from 2019, and the comments indicate it's not going to be solved?

        kkoehneK 1 Reply Last reply
        0
        • JonBJ JonB

          @kkoehne
          Just so I understand: that bug is "critical" but "unresolved" from 2019, and the comments indicate it's not going to be solved?

          kkoehneK Offline
          kkoehneK Offline
          kkoehne
          Moderators
          wrote on last edited by
          #4

          @JonB Yeah, something went wrong here. Will follow up.

          Director R&D, The Qt Company

          1 Reply Last reply
          0
          • kkoehneK kkoehne

            You don't say anything about the input XML, but this sounds like https://bugreports.qt.io/browse/QTBUG-75456 .

            O Offline
            O Offline
            Owen_cn
            wrote on last edited by
            #5

            @kkoehne

            the input xml start element is like <tagXXX>
            and int the new file the start element is n1:tagXXX

            kkoehneK JonBJ 2 Replies Last reply
            0
            • O Owen_cn

              @kkoehne

              the input xml start element is like <tagXXX>
              and int the new file the start element is n1:tagXXX

              kkoehneK Offline
              kkoehneK Offline
              kkoehne
              Moderators
              wrote on last edited by
              #6

              @Owen_cn said in how to use QXmlStreamWriter ::writeCurrentToken:

              the input xml start element is like <tagXXX>
              and int the new file the start element is n1:tagXXX

              But is tagXXX in a 'default' namespace? That is, does your input XML have a "xmlns" attribute?

              If you have a minimal XML, we could see whether it is indeed QTBUG-75456, or something else.

              Director R&D, The Qt Company

              1 Reply Last reply
              0
              • O Owen_cn

                @kkoehne

                the input xml start element is like <tagXXX>
                and int the new file the start element is n1:tagXXX

                JonBJ Online
                JonBJ Online
                JonB
                wrote on last edited by
                #7

                @Owen_cn said in how to use QXmlStreamWriter ::writeCurrentToken:

                the input xml start element is like <tagXXX>
                and int the new file the start element is n1:tagXXX

                Is this not exactly what that bug report describes?

                1 Reply Last reply
                0
                • O Offline
                  O Offline
                  Owen_cn
                  wrote on last edited by
                  #8

                  for example the source xml file
                  //
                  <?xml version="1.0" encoding="ISO-8859-1"?>
                  <indexedmzML xmlns="http://psi.hupo.org/ms/mzml">
                  <mzML xmlns="http://psi.hupo.org/ms/mzml">
                  </mzML>
                  </indexedmzML>

                  use writeCurrentToken to write a new file, the output is like this

                  <?xml version="1.0" encoding="ISO-8859-1"?>
                  <n1:indexedmzML xmlns="http://psi.hupo.org/ms/mzml">
                  <n1:mzML xmlns="http://psi.hupo.org/ms/mzml">
                  n1:/mzML
                  n1:/indexedmzML

                  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