The DOMElement class

(PHP 5, PHP 7, PHP 8)

Class synopsis

classDOMElementextendsDOMNodeimplementsDOMParentNode, DOMChildNode {
publicreadonlystring$tagName;
publicstring$id;
publicreadonlymixed$schemaTypeInfo = null;
publicreadonlyint$childElementCount;
publicreadonlystring$nodeName;
publicreadonlyint$nodeType;
publicreadonly?DOMNode$parentNode;
publicreadonly?DOMElement$parentElement;
publicreadonlyDOMNodeList$childNodes;
publicreadonly?DOMNode$firstChild;
publicreadonly?DOMNode$lastChild;
publicreadonly?DOMNode$previousSibling;
publicreadonly?DOMNode$nextSibling;
publicreadonlybool$isConnected;
publicreadonly?string$namespaceURI;
publicreadonly?string$localName;
publicreadonly?string$baseURI;
public__construct(string$qualifiedName, ?string$value = null, string$namespace = "")
publicafter(DOMNode|string...$nodes): void
publicappend(DOMNode|string...$nodes): void
publicbefore(DOMNode|string...$nodes): void
publicgetAttribute(string$qualifiedName): string
publicgetAttributeNS(?string$namespace, string$localName): string
publicgetElementsByTagNameNS(?string$namespace, string$localName): DOMNodeList
publichasAttribute(string$qualifiedName): bool
publichasAttributeNS(?string$namespace, string$localName): bool
publicinsertAdjacentText(string$where, string$data): void
publicprepend(DOMNode|string...$nodes): void
publicremove(): void
publicremoveAttribute(string$qualifiedName): bool
publicremoveAttributeNS(?string$namespace, string$localName): void
publicreplaceWith(DOMNode|string...$nodes): void
publicsetAttribute(string$qualifiedName, string$value): DOMAttr|bool
publicsetAttributeNS(?string$namespace, string$qualifiedName, string$value): void
publicsetIdAttribute(string$qualifiedName, bool$isId): void
publicsetIdAttributeNode(DOMAttr$attr, bool$isId): void
publicsetIdAttributeNS(string$namespace, string$qualifiedName, bool$isId): void
publictoggleAttribute(string$qualifiedName, ?bool$force = null): bool
publicDOMNode::C14N(
    bool$exclusive = false,
    bool$withComments = false,
    ?array$xpath = null,
    ?array$nsPrefixes = null
): string|false
publicDOMNode::C14NFile(
    string$uri,
    bool$exclusive = false,
    bool$withComments = false,
    ?array$xpath = null,
    ?array$nsPrefixes = null
): int|false
publicDOMNode::isSameNode(DOMNode$otherNode): bool
publicDOMNode::isSupported(string$feature, string$version): bool
}

Properties

childElementCount

The number of child elements.

firstElementChild

First child element or null.

lastElementChild

Last child element or null.

nextElementSibling

The next sibling element or null.

previousElementSibling

The previous sibling element or null.

schemaTypeInfo

Not implemented yet, always return null

tagName

The element name

className

A string representing the classes of the element separated by spaces

id

The element ID

Changelog

VersionDescription
8.0.0 The firstElementChild, lastElementChild, childElementCount, previousElementSibling, and nextElementSibling properties have been added.
8.0.0DOMElement implements DOMParentNode and DOMChildNode now.

Notes

Note:

The DOM extension uses UTF-8 encoding. Use mb_convert_encoding(), UConverter::transcode(), or iconv() to handle other encodings.

Table of Contents

To Top