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. Qt6 QDomDocument setContent with String input error
Forum Updated to NodeBB v4.3 + New Features

Qt6 QDomDocument setContent with String input error

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 239 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.
  • B Offline
    B Offline
    Bilal Can
    wrote on 5 Jan 2024, 09:10 last edited by Bilal Can 1 May 2024, 09:16
    #1

    Hi all,

    I have the code below:

        QString oXmlStream = QString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        QDomDocument o_dom_doc;
        QString oErrorMsg;
        int oErrLine = 0;
        int oErrCol = 0;
        if(!o_dom_doc.setContent(oXmlStream,&oErrorMsg, &oErrLine,&oErrCol))
        {
            qWarning() << oErrorMsg << " at line: " << oErrLine << " col: " << oErrCol;
            return;
        }
    

    When I try to run this I get an error: "Premature end of document." at line: 1 col: 1

    If I change the xml string like below, I get error message: unable to set content for nav mod: Expected '>' or '/', but got '[a-zA-Z]'.

    QString oXmlStream = QString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") +
    QString("<item name_org=\"") + QString(QApplication::translate("Navigator", "Components")) + QString("\"") +
    QString("icon_path=\":/icons/components.png\"") +
    QString("tab_path=\"components\"") +
    QString(">") +
    QString("</item>");
    

    These codes were working in Qt5.15.14 version without giving an error, but after qt6.5.2 update it gives the error message. How can I fix the issue. The xml text is valid

    C 1 Reply Last reply 5 Jan 2024, 09:20
    0
    • B Bilal Can
      5 Jan 2024, 09:10

      Hi all,

      I have the code below:

          QString oXmlStream = QString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
          QDomDocument o_dom_doc;
          QString oErrorMsg;
          int oErrLine = 0;
          int oErrCol = 0;
          if(!o_dom_doc.setContent(oXmlStream,&oErrorMsg, &oErrLine,&oErrCol))
          {
              qWarning() << oErrorMsg << " at line: " << oErrLine << " col: " << oErrCol;
              return;
          }
      

      When I try to run this I get an error: "Premature end of document." at line: 1 col: 1

      If I change the xml string like below, I get error message: unable to set content for nav mod: Expected '>' or '/', but got '[a-zA-Z]'.

      QString oXmlStream = QString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") +
      QString("<item name_org=\"") + QString(QApplication::translate("Navigator", "Components")) + QString("\"") +
      QString("icon_path=\":/icons/components.png\"") +
      QString("tab_path=\"components\"") +
      QString(">") +
      QString("</item>");
      

      These codes were working in Qt5.15.14 version without giving an error, but after qt6.5.2 update it gives the error message. How can I fix the issue. The xml text is valid

      C Online
      C Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 5 Jan 2024, 09:20 last edited by
      #2

      Output the full string and check if the xml is valid - I would guess it's not.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      B 1 Reply Last reply 5 Jan 2024, 10:03
      2
      • C Christian Ehrlicher
        5 Jan 2024, 09:20

        Output the full string and check if the xml is valid - I would guess it's not.

        B Offline
        B Offline
        Bilal Can
        wrote on 5 Jan 2024, 10:03 last edited by
        #3

        @Christian-Ehrlicher

        I realized that there is no space between attributes inside a tag. It is interesting that old qt version does not complain about it. Thanks for the advice

        1 Reply Last reply
        0
        • B Bilal Can has marked this topic as solved on 5 Jan 2024, 13:11

        1/3

        5 Jan 2024, 09:10

        • Login

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