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
QtWS25 Last Chance

Qt6 QDomDocument setContent with String input error

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 224 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 last edited by Bilal Can
    #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

    Christian EhrlicherC 1 Reply Last reply
    0
    • B Bilal Can

      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

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 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
      2
      • Christian EhrlicherC Christian Ehrlicher

        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 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

        • Login

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