Die Klasse DOMElement

(PHP 5, PHP 7, PHP 8)

Klassenbeschreibung

class DOMElement extends DOMNode implements DOMParentNode, DOMChildNode {
/* Geerbte Konstanten */
/* Eigenschaften */
public readonly string $tagName;
public string $id;
public readonly mixed $schemaTypeInfo;
public readonly ?DOMElement $firstElementChild;
public readonly ?DOMElement $lastElementChild;
public readonly int $childElementCount;
/* Geerbte Eigenschaften */
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;
/* Methoden */
public function __construct(string $qualifiedName, ?string $value = null, string $namespace = "")
public function after(DOMNode|string ...$nodes): void
public function append(DOMNode|string ...$nodes): void
public function before(DOMNode|string ...$nodes): void
public function getAttribute(string $qualifiedName): string
public function getAttributeNames(): array
public function getAttributeNode(string $qualifiedName): DOMAttr|DOMNameSpaceNode|false
public function getAttributeNodeNS(?string $namespace, string $localName): DOMAttr|DOMNameSpaceNode|null
public function getAttributeNS(?string $namespace, string $localName): string
public function getElementsByTagName(string $qualifiedName): DOMNodeList
public function getElementsByTagNameNS(?string $namespace, string $localName): DOMNodeList
public function hasAttribute(string $qualifiedName): bool
public function hasAttributeNS(?string $namespace, string $localName): bool
public function insertAdjacentElement(string $where, DOMElement $element): ?DOMElement
public function insertAdjacentText(string $where, string $data): void
public function prepend(DOMNode|string ...$nodes): void
public function remove(): void
public function removeAttribute(string $qualifiedName): bool
public function removeAttributeNode(DOMAttr $attr): DOMAttr|false
public function removeAttributeNS(?string $namespace, string $localName): void
public function replaceChildren(DOMNode|string ...$nodes): void
public function replaceWith(DOMNode|string ...$nodes): void
public function setAttribute(string $qualifiedName, string $value): DOMAttr|bool
public function setAttributeNode(DOMAttr $attr): DOMAttr|null|false
public function setAttributeNodeNS(DOMAttr $attr): DOMAttr|null|false
public function setAttributeNS(?string $namespace, string $qualifiedName, string $value): void
public function setIdAttribute(string $qualifiedName, bool $isId): void
public function setIdAttributeNode(DOMAttr $attr, bool $isId): void
public function setIdAttributeNS(string $namespace, string $qualifiedName, bool $isId): void
public function toggleAttribute(string $qualifiedName, ?bool $force = null): bool
/* Geerbte Methoden */
public function DOMNode::appendChild(DOMNode $node): DOMNode|false
public function DOMNode::C14N(
    bool $exclusive = false,
    bool $withComments = false,
    ?array $xpath = null,
    ?array $nsPrefixes = null
): string|false
public function DOMNode::C14NFile(
    string $uri,
    bool $exclusive = false,
    bool $withComments = false,
    ?array $xpath = null,
    ?array $nsPrefixes = null
): int|false
public function DOMNode::cloneNode(bool $deep = false): DOMNode|false
public function DOMNode::getLineNo(): int
public function DOMNode::getNodePath(): ?string
public function DOMNode::getRootNode(?array $options = null): DOMNode
public function DOMNode::hasAttributes(): bool
public function DOMNode::hasChildNodes(): bool
public function DOMNode::insertBefore(DOMNode $node, ?DOMNode $child = null): DOMNode|false
public function DOMNode::isDefaultNamespace(string $namespace): bool
public function DOMNode::isEqualNode(?DOMNode $otherNode): bool
public function DOMNode::isSameNode(DOMNode $otherNode): bool
public function DOMNode::isSupported(string $feature, string $version): bool
public function DOMNode::lookupNamespaceURI(?string $prefix): ?string
public function DOMNode::lookupPrefix(string $namespace): ?string
public function DOMNode::normalize(): void
public function DOMNode::removeChild(DOMNode $child): DOMNode|false
public function DOMNode::replaceChild(DOMNode $node, DOMNode $child): DOMNode|false
public function DOMNode::__sleep(): array
public function DOMNode::__wakeup(): void
}

Eigenschaften

childElementCount

Die Anzahl der Kindelemente.

firstElementChild

Erstes Kindelement oder null.

lastElementChild

Letztes Kindelement oder null.

nextElementSibling

Das nächste Geschwisterelement oder null.

previousElementSibling

Das vorherige Geschwisterelement oder null.

schemaTypeInfo

Noch nicht implementiert, gibt immer null zurück

tagName

Der Name des Elements

className

Eine Zeichenkette, die die Klassen des Elements durch Leerzeichen getrennt darstellt.

id

Gibt die Element-ID durch das Attribut "id" wieder.

Changelog

Version Beschreibung
8.3.0 Die Eigenschaften className und id und die Methoden DOMElement::getAttributeNames(), DOMElement::insertAdjacentElement(), DOMElement::insertAdjacentText() und DOMElement::toggleAttribute() wurden hinzugefügt.
8.0.0 Die Eigenschaften firstElementChild, lastElementChild, childElementCount, previousElementSibling, und nextElementSibling wurden hinzugefügt.
8.0.0 DOMElement implementiert nun DOMParentNode und DOMChildNode.

Anmerkungen

Hinweis:

Die Erweiterung DOM verwendet die UTF-8 Kodierung. Es kann mb_convert_encoding(), UConverter::transcode() oder iconv() verwendet werden, um mit anderen Zeichenkodierungen zu arbeiten.

Inhaltsverzeichnis