Qt6 QDomDocument setContent with String input error
-
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
-
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
Output the full string and check if the xml is valid - I would guess it's not.
-
Output the full string and check if the xml is valid - I would guess it's not.
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
-