Forum PHP 2025

The Dom\Element class

(PHP 8 >= 8.4.0)

はじめに

Represents an element.

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

クラス概要

class Dom\Element extends Dom\Node implements Dom\ParentNode, Dom\ChildNode {
/* 継承した定数 */
/* プロパティ */
public readonly ?string $namespaceURI;
public readonly ?string $prefix;
public readonly string $localName;
public readonly string $tagName;
public string $id;
public readonly Dom\TokenList $classList;
public readonly Dom\NamedNodeMap $attributes;
public readonly ?Dom\Element $lastElementChild;
public readonly int $childElementCount;
/* 継承したプロパティ */
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 */
/* 継承したメソッド */
/* Not documented yet */
}

プロパティ

namespaceURI
The namespace URI of the element.
prefix
The namespace prefix of the element.
localName
The local name of the element.
tagName
The HTML-uppercased qualified name of the element.
className

スペースで分割された、要素のクラスを表す文字列

classList
Returns an instance of Dom\TokenList to easily manage the classes on this element.
attributes
Returns an instance of Dom\NamedNodeMap that represents the attributes of this element.
id

"id" 属性を通して反映される要素のID

firstElementChild

最初の子要素。存在しない場合は null になります。

lastElementChild

最後の子要素。存在しない場合は null になります。

childElementCount

子要素の数。

previousElementSibling

前の兄弟要素。存在しない場合は null になります。

nextElementSibling

次の兄弟要素。存在しない場合は null になります。

innerHTML
The inner HTML (or XML for XML documents) of the element.
substitutedNodeValue
The node value with entity substitution enabled.

注意

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

add a note

User Contributed Notes

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