La classe DOMElement

(PHP 5, PHP 7, PHP 8)

Synopsis de la classe

class DOMElement extends DOMNode implements DOMParentNode, DOMChildNode {
/* Constantes héritées */
/* Propriétés */
public readonly string $tagName;
public string $id;
public readonly mixed $schemaTypeInfo = null;
public readonly ?DOMElement $firstElementChild;
public readonly ?DOMElement $lastElementChild;
public readonly int $childElementCount;
/* Propriétés héritées */
public readonly string $nodeName;
public readonly int $nodeType;
public readonly ?DOMNode $parentNode;
public readonly ?DOMElement $parentElement;
public readonly DOMNodeList $childNodes;
public readonly ?DOMNode $firstChild;
public readonly ?DOMNode $lastChild;
public readonly ?DOMNode $previousSibling;
public readonly ?DOMNode $nextSibling;
public readonly ?DOMNamedNodeMap $attributes;
public readonly bool $isConnected;
public readonly ?DOMDocument $ownerDocument;
public readonly ?string $namespaceURI;
public string $prefix;
public readonly ?string $localName;
public readonly ?string $baseURI;
/* Méthodes */
public __construct(string $qualifiedName, ?string $value = null, string $namespace = "")
public after(DOMNode|string ...$nodes): void
public append(DOMNode|string ...$nodes): void
public before(DOMNode|string ...$nodes): void
public getAttribute(string $qualifiedName): string
public getAttributeNS(?string $namespace, string $localName): string
public getElementsByTagName(string $qualifiedName): DOMNodeList
public getElementsByTagNameNS(?string $namespace, string $localName): DOMNodeList
public hasAttribute(string $qualifiedName): bool
public hasAttributeNS(?string $namespace, string $localName): bool
public insertAdjacentText(string $where, string $data): void
public prepend(DOMNode|string ...$nodes): void
public remove(): void
public removeAttribute(string $qualifiedName): bool
public removeAttributeNS(?string $namespace, string $localName): void
public replaceChildren(DOMNode|string ...$nodes): void
public replaceWith(DOMNode|string ...$nodes): void
public setAttribute(string $qualifiedName, string $value): DOMAttr|bool
public setAttributeNS(?string $namespace, string $qualifiedName, string $value): void
public setIdAttribute(string $qualifiedName, bool $isId): void
public setIdAttributeNode(DOMAttr $attr, bool $isId): void
public setIdAttributeNS(string $namespace, string $qualifiedName, bool $isId): void
public toggleAttribute(string $qualifiedName, ?bool $force = null): bool
/* Méthodes héritées */
public DOMNode::C14N(
    bool $exclusive = false,
    bool $withComments = false,
    ?array $xpath = null,
    ?array $nsPrefixes = null
): string|false
public DOMNode::C14NFile(
    string $uri,
    bool $exclusive = false,
    bool $withComments = false,
    ?array $xpath = null,
    ?array $nsPrefixes = null
): int|false
public DOMNode::isEqualNode(?DOMNode $otherNode): bool
public DOMNode::isSameNode(DOMNode $otherNode): bool
public DOMNode::isSupported(string $feature, string $version): bool
}

Propriétés

childElementCount

Le nombre d'éléments enfants.

firstElementChild

Premier élément enfant ou null.

lastElementChild

Dernier élément enfant ou null.

nextElementSibling

L'élément frère suivant ou null.

previousElementSibling

L'élément frère précédent ou null.

schemaTypeInfo

Pas encore implémenté, retourne toujours null

tagName

Le nom de l'élément

className

Une chaîne représentant les classes de l'élément, séparé par des espaces.

id

Reflète l'ID de l'élément via l'attribut "id".

Historique

Version Description
8.3.0 Les propriétés className et id et les méthodes DOMElement::getAttributeNames(), DOMElement::insertAdjacentElement(), DOMElement::insertAdjacentText(), et DOMElement::toggleAttribute() ont été ajoutées.
8.0.0 Les propriétés firstElementChild, lastElementChild, childElementCount, previousElementSibling et nextElementSibling ont été ajoutées.
8.0.0 DOMElement implémente désormais DOMParentNode et DOMChildNode.

Notes

Note:

L'extension DOM utilise l'encodage UTF-8. Utilisez mb_convert_encoding(), UConverter::transcode(), ou iconv() pour manipuler d'autres encodages.

Sommaire