Obsolete Members for QDomDocument

以下成员源于类 QDomDocument 被弃用。 提供它们是为使旧源代码能继续工作。强烈建议不要在新代码中使用它们。

公共函数

(deprecated (6.8)) bool setContent (const QByteArray & data , bool namespaceProcessing , QString * errorMsg = nullptr, int * errorLine = nullptr, int * errorColumn = nullptr)
(deprecated (6.8)) bool setContent (const QString & text , bool namespaceProcessing , QString * errorMsg = nullptr, int * errorLine = nullptr, int * errorColumn = nullptr)
(deprecated (6.8)) bool setContent (QIODevice * dev , bool namespaceProcessing , QString * errorMsg = nullptr, int * errorLine = nullptr, int * errorColumn = nullptr)
(deprecated (6.8)) bool setContent (const QByteArray & buffer , QString * errorMsg , int * errorLine = nullptr, int * errorColumn = nullptr)
(deprecated (6.8)) bool setContent (const QString & text , QString * errorMsg , int * errorLine = nullptr, int * errorColumn = nullptr)
(deprecated (6.8)) bool setContent (QIODevice * dev , QString * errorMsg , int * errorLine = nullptr, int * errorColumn = nullptr)
(deprecated (6.8)) bool setContent (QXmlStreamReader * reader , bool namespaceProcessing , QString * errorMsg = nullptr, int * errorLine = nullptr, int * errorColumn = nullptr)

成员函数文档编制

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 代替。

这是重载函数。

此函数剖析 XML 文档从字节数组 data 并将它设为文档内容。它试着按 XML 规范要求检测文档编码。

namespaceProcessing 为 true,剖析器识别 XML 文件中的名称空间并将前缀名称、本地名称和名称空间 URI 设为适当值。若 namespaceProcessing 为 false,剖析器不处理名称空间当它读取 XML 文件时。

若发生剖析错误,此函数返回 false 且错误消息放置于 * errorMsg ,行号在 * errorLine 和列号在 * errorColumn (unless the associated pointer is set to nullptr ); otherwise this function returns true .

namespaceProcessing 为 true,函数 QDomNode::prefix () 返回所有元素和属性的字符串。它返回空字符串,若元素或属性没有前缀。

仅剥离由空白组成的文本节点,且不会出现在 QDomDocument .

namespaceProcessing 为 false,函数 QDomNode::prefix (), QDomNode::localName () 和 QDomNode::namespaceURI () 返回空字符串。

实体引用处理如下:

  • 包括出现在内容中的内部一般实体和字符实体的引用。结果是 QDomText 节点,具有被其相应实体值所替换的引用。
  • 包括出现在内部子集中的参数实体的引用。结果是 QDomDocumentType 节点,包含实体和符号声明 (具有被其相应实体值所替换的引用)。
  • 未在内部子集中定义且出现在内容中的任何一般剖析实体引用,被表示成 QDomEntityReference 节点。
  • 任何未在内部子集中定义且出现在内容之外的经剖析实体引用,都被替换为空字符串。
  • 任何未剖析实体引用被替换为空字符串。

另请参阅 QDomNode::namespaceURI (), QDomNode::localName (), QDomNode::prefix (), QString::isNull (),和 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 代替。

此函数读取 XML 文档从字符串 text ,返回 true 若内容被成功剖析;否则返回 false 。由于 text 已经是 Unicode 字符串,不用做编码检测。

bool QDomDocument:: setContent ( QIODevice * dev , 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 代替。

此函数读取 XML 文档从 IO 设备 dev ,返回 true 若内容被成功剖析;否则返回 false .

注意: This method will try to open dev in read-only mode if it is not already open. In that case, the caller is responsible for calling close. This will change in Qt 7, which will no longer open dev . Applications should therefore open the device themselves before calling setContent.

bool QDomDocument:: setContent (const QByteArray & buffer , QString * errorMsg , 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 returning ParseResult 代替。

此函数读取 XML 文档从字节数组 buffer ,返回 true 若内容被成功剖析;否则返回 false。

不履行名称空间处理。

bool QDomDocument:: setContent (const QString & text , QString * errorMsg , 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 returning ParseResult 代替。

此函数读取 XML 文档从字符串 text ,返回 true 若内容被成功剖析;否则返回 false 。由于 text 已经是 Unicode 字符串,不用履行编码检测。

也不履行名称空间处理。

bool QDomDocument:: setContent ( QIODevice * dev , QString * errorMsg , 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 returning ParseResult 代替。

此函数读取 XML 文档从 IO 设备 dev ,返回 true 若内容被成功剖析;否则返回 false .

不履行名称空间处理。

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 代替。

此函数读取 XML 文档从 QXmlStreamReader reader 并剖析它。返回 true 若内容被成功解析;否则返回 false .

namespaceProcessing is true ,剖析器识别 XML 文件中的名称空间并将前缀名称、本地名称和名称空间 URI 设为适当值。若 namespaceProcessing is false ,剖析器不处理名称空间当它读取 XML 文件时。

若发生剖析错误,错误消息放置在 * errorMsg ,行号在 * errorLine 和列号在 * errorColumn (unless the associated pointer is set to nullptr ).

另请参阅 QXmlStreamReader .