QDomProcessingInstruction 類

QDomProcessingInstruction 類錶示 XML (可擴展標記語言) 處理指令。 更多...

頭: #include <QDomProcessingInstruction>
CMake: 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 聲明不是處理指令;除其它差異外,不可以將其插入文檔任何地方,但可插入第一行。

注意: Do not use this function to create an XML declaration. Although the XML declaration shares the same syntax as a processing instruction, it is not one. According to the XML 1.0 Specification W3C DOM Structure Model , the XML declaration is part of the document prolog and not part of the DOM tree - meaning it should not be represented as a DOM node and cannot be created or inserted via the DOM API. If you need to generate a well-formed XML document that includes an XML declaration, use QXmlStreamWriter , which provides proper support for writing the declaration through writeStartDocument .

處理指令內容的檢索采用 data () 和設置采用 setData ()。處理指令目標的檢索采用 target ().

有關文檔對象模型的進一步信息,見 級彆 1 and 級彆 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 ().