This is an overloaded function.
bool
QDomDocument::
setContent
(
QXmlStreamReader
*
reader
,
bool
namespaceProcessing
,
QString
*
errorMsg
= nullptr,
int
*
errorLine
= nullptr,
int
*
errorColumn
= nullptr)
This function is deprecated since 6.8. We strongly advise against using it in new code.
Use the overload taking
ParseOptions
instead.
This function reads the XML document from the
QXmlStreamReader
reader
and parses it. Returns
true
if the content was successfully parsed; otherwise returns
false
.
If
namespaceProcessing
is
true
, the parser recognizes namespaces in the XML file and sets the prefix name, local name and namespace URI to appropriate values. If
namespaceProcessing
is
false
, the parser does no namespace processing when it reads the XML file.
If a parse error occurs, the error message is placed in
*
errorMsg
, the line number in
*
errorLine
and the column number in
*
errorColumn
(unless the associated pointer is set to
nullptr
).
This is an overloaded function.
See also
QXmlStreamReader
.
bool
QDomDocument::
setContent
(const
QByteArray
&
data
,
bool
namespaceProcessing
,
QString
*
errorMsg
= nullptr,
int
*
errorLine
= nullptr,
int
*
errorColumn
= nullptr)
This function is deprecated since 6.8. We strongly advise against using it in new code.
Use the overload taking
ParseOptions
instead.
This function parses the XML document from the byte array
data
and sets it as the content of the document. It tries to detect the encoding of the document as required by the XML specification.
If
namespaceProcessing
is true, the parser recognizes namespaces in the XML file and sets the prefix name, local name and namespace URI to appropriate values. If
namespaceProcessing
is false, the parser does no namespace processing when it reads the XML file.
If a parse error occurs, this function returns
false
and the error message is placed in
*
errorMsg
, the line number in
*
errorLine
and the column number in
*
errorColumn
(unless the associated pointer is set to
nullptr
); otherwise this function returns
true
.
If
namespaceProcessing
is true, the function
QDomNode::prefix
() returns a string for all elements and attributes. It returns an empty string if the element or attribute has no prefix.
Text nodes consisting only of whitespace are stripped and won't appear in the
QDomDocument
.
If
namespaceProcessing
is false, the functions
QDomNode::prefix
(),
QDomNode::localName
() and
QDomNode::namespaceURI
() return an empty string.
Entity references are handled as follows:
References to internal general entities and character entities occurring in the content are included. The result is a
QDomText
node with the references replaced by their corresponding entity values.
References to parameter entities occurring in the internal subset are included. The result is a
QDomDocumentType
node which contains entity and notation declarations with the references replaced by their corresponding entity values.
Any general parsed entity reference which is not defined in the internal subset and which occurs in the content is represented as a
QDomEntityReference
node.
Any parsed entity reference which is not defined in the internal subset and which occurs outside of the content is replaced with an empty string.
Any unparsed entity reference is replaced with an empty string.
This is an overloaded function.
See also
QDomNode::namespaceURI
(),
QDomNode::localName
(),
QDomNode::prefix
(),
QString::isNull
(), and
QString::isEmpty
().
bool
QDomDocument::
setContent
(const
QString
&
text
,
bool
namespaceProcessing
,
QString
*
errorMsg
= nullptr,
int
*
errorLine
= nullptr,
int
*
errorColumn
= nullptr)
This function is deprecated since 6.8. We strongly advise against using it in new code.
Use the overloads taking
ParseOptions
instead.
This function reads the XML document from the string
text
, returning true if the content was successfully parsed; otherwise returns
false
. Since
text
is already a Unicode string, no encoding detection is done.
This is an overloaded function.
©
2026 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners. The documentation provided herein is licensed under the terms of the
GNU Free Documentation License version 1.3
as published by the Free Software Foundation. Qt and respective logos are
trademarks
of The Qt Company Ltd. in Finland and/or other countries
worldwide. All other trademarks are property of their respective owners.