QDomProcessingInstruction Class

QDomProcessingInstruction 类表示 XML 处理指令。更多

头文件 #include <QDomProcessingInstruction>
CMake.QDomProcessingInstruction find_package(Qt6 REQUIRED COMPONENTS Xml)
target_link_libraries(mytarget PRIVATE Qt6::Xml)
qmake: QT += xml
继承: QDomNode

注意:该类中的所有函数都是可重入的

公共函数

QDomProcessingInstruction()
QDomProcessingInstruction(const QDomProcessingInstruction &processingInstruction)
QString data() const
QDomNode::NodeType nodeType() const
void setData(const QString &data)
QString target() const
QDomProcessingInstruction &operator=(const QDomProcessingInstruction &other)

详细描述

XML 中使用处理指令将特定于处理器的信息保留在文档文本中。

出现在 XML 文档顶部的 XML 声明(通常为<?xml version='1.0' encoding='UTF-8'?> )被 QDom 视为处理指令。这是很不幸的,因为 XML 声明不是处理指令;除其他不同之处外,它不能插入文档的任何地方,只能在第一行插入。

请勿使用此函数创建 XML 声明,因为尽管它的语法与处理指令相同,但它并不是,而且 QDom 可能不会将其视为处理指令。

处理指令的内容用data() 检索,用setData() 设置。处理指令的目标可通过target() 检索。

有关文档对象模型的更多信息,请参阅第 1 级第 2 级核心。有关 DOM 实现的一般介绍,请参阅QDomDocument 文档。

成员函数文档

QDomProcessingInstruction::QDomProcessingInstruction()

构造空处理指令。使用QDomDocument::createProcessingInstruction() 创建有内容的处理指令。

QDomProcessingInstruction::QDomProcessingInstruction(const QDomProcessingInstruction &processingInstruction)

构造processingInstruction 的副本。

副本的数据是共享的(浅层副本):修改一个节点也会改变另一个节点。如果要进行深度复制,请使用cloneNode() 。

QString QDomProcessingInstruction::data() const

返回该处理指令的内容。

另请参阅 setData() 和target()。

QDomNode::NodeType QDomProcessingInstruction::nodeType() const

返回ProcessingInstructionNode

void QDomProcessingInstruction::setData(const QString &data)

将处理指令中包含的数据设置为data

另请参阅 data() 。

QString QDomProcessingInstruction::target() const

返回此处理指令的目标值。

另请参阅 data().

QDomProcessingInstruction &QDomProcessingInstruction::operator=(const QDomProcessingInstruction &other)

为该处理指令指定other

拷贝的数据是共享的(浅拷贝):修改一个节点也会改变另一个节点。如果要进行深度复制,请使用cloneNode() 。

© 2025 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.