php8.5
Home/ Manual/ reference / dom/ The DOMElement class

The DOMElement class

The number of child elements.

Class synopsis

class DOMElement extends DOMNode implements DOMParentNode implements DOMChildNode { }

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

Reflects the element ID through the "id" attribute.

Changelog

VersionDescription
8.3.0The className and id properties and the DOMElement::getAttributeNames, DOMElement::insertAdjacentElement, DOMElement::insertAdjacentText, and DOMElement::toggleAttribute methods have been added.
8.0.0The firstElementChild, lastElementChild, childElementCount, previousElementSibling, and nextElementSibling properties have been added.
8.0.0DOMElement implements DOMParentNode and DOMChildNode now.

Notes Utf8

Domelement

In this section

DOMElement::__construct

Creates a new DOMElement object

DOMElement::after

Adds nodes after the element

DOMElement::append

Appends nodes after the last child node

DOMElement::before

Adds nodes before the element

DOMElement::getAttribute

Returns value of attribute

DOMElement::getAttributeNS

Returns value of attribute

DOMElement::getAttributeNames

Get attribute names

DOMElement::getAttributeNode

Returns attribute node

DOMElement::getAttributeNodeNS

Returns attribute node

DOMElement::getElementsByTagName

Gets elements by tagname

DOMElement::getElementsByTagNameNS

Get elements by namespaceURI and localName

DOMElement::hasAttribute

Checks to see if attribute exists

DOMElement::hasAttributeNS

Checks to see if attribute exists

DOMElement::insertAdjacentElement

Insert adjacent element

DOMElement::insertAdjacentText

Insert adjacent text

DOMElement::prepend

Prepends nodes before the first child node

DOMElement::remove

Removes the element

DOMElement::removeAttribute

Removes attribute

DOMElement::removeAttributeNS

Removes attribute

DOMElement::removeAttributeNode

Removes attribute

DOMElement::replaceChildren

Replace children in element

DOMElement::replaceWith

Replaces the element with new nodes

DOMElement::setAttribute

Adds new or modifies existing attribute

DOMElement::setAttributeNS

Adds new attribute

DOMElement::setAttributeNode

Adds new attribute node to element

DOMElement::setAttributeNodeNS

Adds new attribute node to element

DOMElement::setIdAttribute

Declares the attribute specified by name to be of type ID

DOMElement::setIdAttributeNS

Declares the attribute specified by local name and namespace URI to be of type ID

DOMElement::setIdAttributeNode

Declares the attribute specified by node to be of type ID

DOMElement::toggleAttribute

Toggle attribute

Source: reference/dom/domelement.xml · from the official PHP manual (php/doc-en)