The DOMNode class

(PHP 5, PHP 7)

类摘要

DOMNode {
/* 属性 */
public readonly string $nodeName ;
public string $nodeValue ;
public readonly int $nodeType ;
public readonly DOMNode|null $parentNode ;
public readonly DOMNodeList $childNodes ;
public readonly DOMNode|null $firstChild ;
public readonly DOMNode|null $lastChild ;
public readonly DOMNode|null $previousSibling ;
public readonly DOMNode|null $nextSibling ;
public readonly DOMNamedNodeMap|null $attributes ;
public readonly DOMDocument|null $ownerDocument ;
public readonly string|null $namespaceURI ;
public string $prefix ;
public readonly string $localName ;
public readonly string|null $baseURI ;
public string $textContent ;
/* 方法 */
public appendChild ( DOMNode $node ) : DOMNode|false
public C14N ( bool $exclusive = false , bool $withComments = false , array|null $xpath = null , array|null $nsPrefixes = null ) : string|false
public C14NFile ( string $uri , bool $exclusive = false , bool $withComments = false , array|null $xpath = null , array|null $nsPrefixes = null ) : int|false
public cloneNode ( bool $deep = false ) : DOMNode|false
public getLineNo ( ) : int
public getNodePath ( ) : string|null
public hasAttributes ( ) : bool
public hasChildNodes ( ) : bool
public insertBefore ( DOMNode $node , DOMNode|null $child = null ) : DOMNode|false
public isDefaultNamespace ( string $namespace ) : bool
public isSameNode ( DOMNode $otherNode ) : bool
public isSupported ( string $feature , string $version ) : bool
public lookupNamespaceUri ( string $prefix ) : string
public lookupPrefix ( string $namespace ) : string|null
public normalize ( ) : void
public removeChild ( DOMNode $child ) : DOMNode|false
public replaceChild ( DOMNode $node , DOMNode $child ) : DOMNode|false
}

属性

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_xxx_NODE constants

parentNode

The parent of this node. If there is no such node, 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.

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, or null if it is unspecified.

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.

注释

注意:

此 DOM 扩展采用 UTF-8 编码。在 ISO-8859-1 编码下,使用 utf8_encode()utf8_decode() 来处理,其它编码下使用 iconv 函数处理。

目录