The DOMNode class

Class synopsis

DOMNode
/* Properties */
public readonly string $nodeName;
public stringnull $nodeValue;
public readonly int $nodeType;
public readonly DOMNodenull $parentNode;
public readonly DOMElementnull $parentElement;
public readonly DOMNodeList $childNodes;
public readonly DOMNodenull $firstChild;
public readonly DOMNodenull $lastChild;
public readonly DOMNodenull $previousSibling;
public readonly DOMNodenull $nextSibling;
public readonly DOMNamedNodeMapnull $attributes;
public readonly bool $isConnected;
public readonly DOMDocumentnull $ownerDocument;
public readonly stringnull $namespaceURI;
public string $prefix;
public readonly stringnull $localName;
public readonly stringnull $baseURI;
public string $textContent;
/* Methods */
public DOMNodefalse appendChild(DOMNode $node)
public stringfalse C14N(
    bool $exclusive = false,
    bool $withComments = false,
    arraynull $xpath = null,
    arraynull $nsPrefixes = null
)
public intfalse C14NFile(
    string $uri,
    bool $exclusive = false,
    bool $withComments = false,
    arraynull $xpath = null,
    arraynull $nsPrefixes = null
)
public DOMNodefalse cloneNode(bool $deep = false)
public bool contains(DOMNodeDOMNameSpaceNodenull $other)
public int getLineNo()
public stringnull getNodePath()
public DOMNode getRootNode(arraynull $options = null)
public bool hasAttributes()
public bool hasChildNodes()
public DOMNodefalse insertBefore(DOMNode $node, DOMNodenull $child = null)
public bool isDefaultNamespace(string $namespace)
public bool isEqualNode(DOMNodenull $otherNode)
public bool isSameNode(DOMNode $otherNode)
public bool isSupported(string $feature, string $version)
public stringnull lookupNamespaceURI(stringnull $prefix)
public stringnull lookupPrefix(string $namespace)
public void normalize()
public DOMNodefalse removeChild(DOMNode $child)
public DOMNodefalse replaceChild(DOMNode $node, DOMNode $child)

Properties

nodeName

Returns the most accurate name for the current node type

nodeValue

The value of this node, depending on its type. Contrary to the W3C specification, the node value of DOMElement nodes is equal to DOMNode::textContent instead of null.

nodeType

Gets the type of the node. One of the predefined XML_*_NODE constants

parentNode

The parent of this node. If there is no such node, this returns null.

parentElement

The parent element of this element. If there is no such element, this returns null.

childNodes

A DOMNodeList that contains all children of this node. If there are no children, this is an empty DOMNodeList.

firstChild

The first child of this node. If there is no such node, this returns null.

lastChild

The last child of this node. If there is no such node, this returns null.

previousSibling

The node immediately preceding this node. If there is no such node, this returns null.

nextSibling

The node immediately following this node. If there is no such node, this returns null.

attributes

A DOMNamedNodeMap containing the attributes of this node (if it is a DOMElement) or null otherwise.

isConnected

Whether the node is connected to a document

ownerDocument

The DOMDocument object associated with this node, or null if this node is a DOMDocument

namespaceURI

The namespace URI of this node, or null if it is unspecified.

prefix

The namespace prefix of this node.

localName

Returns the local part of the qualified name of this node.

baseURI

The absolute base URI of this node or null if the implementation wasn't able to obtain an absolute URI.

textContent

The text content of this node and its descendants.

Changelog

Version Description
8.3.0 Properties DOMNode::$parentElement, and DOMNode::$isConnected have been added.
8.0.0 The unimplemented methods DOMNode::compareDocumentPosition, DOMNode::isEqualNode, DOMNode::getFeature, DOMNode::setUserData and DOMNode::getUserData have been removed.

Notes

Note:

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

Table of Contents