このページでは

QDomProcessingInstruction Class

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 宣言は処理命令ではないからです。他の違いもいくつかありますが、とりわけ、XML 宣言はドキュメントの 1 行目にしか挿入できないという違いがあります。

注: この関数を使用して XML 宣言を作成しないでください 。XML 宣言は処理命令と同じ構文を共有していますが、処理命令そのものではありません。XML 1.0仕様 およびW3C DOM構造モデルによれば、XML宣言はドキュメントプロローグの一部であり、DOMツリーの一部ではありません。つまり、DOMノードとして表現されるべきではなく、DOM APIを介して作成または挿入することはできません。 XML 宣言を含む、整形式の XML ドキュメントを生成する必要がある場合は、QXmlStreamWriter を使用してください。このメソッドは、writeStartDocument を通じて宣言を記述するための適切なサポートを提供します。

処理命令の内容は、data() で取得し、setData() で設定します。処理命令のターゲットは、target() で取得します。

Document Object Model(DOM)に関する詳細については、Level 1およびLevel 2 Core を参照してください。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() を使用してください。

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