Forum PHP 2025

The Dom\Node class

(PHP 8 >= 8.4.0)

はじめに

This is the modern, spec-compliant equivalent of DOMNode.

クラス概要

class Dom\Node {
/* 定数 */
public const int DOCUMENT_POSITION_DISCONNECTED = 0x1;
public const int DOCUMENT_POSITION_PRECEDING = 0x2;
public const int DOCUMENT_POSITION_FOLLOWING = 0x4;
public const int DOCUMENT_POSITION_CONTAINS = 0x8;
public const int DOCUMENT_POSITION_CONTAINED_BY = 0x10;
/* プロパティ */
public readonly int $nodeType;
public readonly string $nodeName;
public readonly string $baseURI;
public readonly bool $isConnected;
public readonly ?Dom\Document $ownerDocument;
public readonly ?Dom\Node $parentNode;
public readonly ?Dom\Element $parentElement;
public readonly Dom\NodeList $childNodes;
public readonly ?Dom\Node $firstChild;
public readonly ?Dom\Node $lastChild;
public readonly ?Dom\Node $previousSibling;
public readonly ?Dom\Node $nextSibling;
/* メソッド */
/* Not documented yet */
}

定義済み定数

DOMNode::DOCUMENT_POSITION_DISCONNECTED
もう一方のノードと参照ノードが同じツリー内にない場合に設定されます。
DOMNode::DOCUMENT_POSITION_PRECEDING
もう一方のノードが参照ノードより前にある場合に設定されます。
DOMNode::DOCUMENT_POSITION_FOLLOWING
もう一方のノードが参照ノードの後に続く場合に設定されます。
DOMNode::DOCUMENT_POSITION_CONTAINS
もう一方のノードが参照ノードの祖先である場合に設定されます。
DOMNode::DOCUMENT_POSITION_CONTAINED_BY
もう一方のノードが参照ノードの子孫である場合に設定されます。
DOMNode::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC
結果が実装依存の動作に基づいており、移植性がない場合に設定されます。 これは、同じツリー内にないノードや属性ノードの場合に発生する可能性があります。

プロパティ

nodeType

ノードの型を、定義済みの定数 XML_*_NODE のいずれかで返す

nodeName
Returns the most accurate name for the current node type.
  • For elements, this is the HTML-uppercased qualified name.
  • For attributes, this is the qualified name.
  • For processing instructions, this is the target.
  • For document type nodes, this is the name.
baseURI

このノードの完全なベース URI。もし実装が完全な URL を できなかった場合は null

isConnected

ノードが Document に接続されているかどうか

ownerDocument
The Dom\Document object associated with this node, or null if this node is a document.
parentNode

このノードの親 (存在しない場合は null) を返す

parentElement

この要素の親要素。存在しない場合は null を返す

childNodes
A Dom\NodeList that contains all children of this node. If there are no children, this is an empty Dom\NodeList.
firstChild

このノードの最初の子。存在しない場合は null を返す

lastChild

このノードの最後の子。存在しない場合は null を返す

previousSibling

このノードの直前のノード。存在しない場合は null を返す

nextSibling

このノードの直後のノード。存在しない場合は null を返す

nodeValue
The value of this node, depending on its type.
textContent

このノードとその子孫ノードのテキスト

注意

注意: DOM拡張モジュールは、メソッドやプロパティで UTF-8 エンコーディングを使います。 パースをおこなうメソッドは、エンコーディングを自動的に判別し、呼び出し側でエンコーディングを指定することもできます。

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top