PHP 클래스 DiDom\Element

파일 보기 프로젝트 열기: imangazaliev/didom 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$node DOMNode; The DOM element instance.

공개 메소드들

메소드 설명
__construct ( DOMNode | string $name, string $value = null, array $attributes = [] ) Constructor.
__get ( string $name ) : string | null Dynamically access the element's attributes.
__invoke ( string $expression, string $type = Query::TYPE_CSS, boolean $wrapElement = true ) : Element[] | DOMElement[] Searches for an node in the DOM tree for a given XPath expression or a CSS selector.
__isset ( string $name ) : boolean Determine if an attribute exists on the element.
__set ( string $name, mixed $value ) : Element Dynamically set an attribute on the element.
__toString ( ) : string Convert the element to its string representation.
__unset ( string $name ) Unset an attribute on the model.
appendChild ( Element | DOMNode | array $nodes ) : Element Adds new child at the end of the children.
attr ( string $name, string $value = null ) : string | null | Element Alias for getAttribute and setAttribute methods.
attributes ( ) : array | null Returns the node attributes or null, if it is not DOMElement.
child ( $index ) : Element | null
children ( ) : Element[]
cloneNode ( boolean $deep = true ) : Element Clones a node.
closest ( string $selector, boolean $strict = false ) : Element | null Returns first parent node matches passed selector.
count ( string $expression, string $type = Query::TYPE_CSS ) : integer Counts nodes for a given XPath expression or a CSS selector.
create ( DOMNode | string $name, string $value = null, array $attributes = [] ) : Element Create new element.
createBySelector ( string $selector, string $value = null, array $attributes = [] ) : Element Create new element node by CSS selector.
find ( string $expression, string $type = Query::TYPE_CSS, boolean $wrapElement = true ) : Element[] | DOMElement[] Searches for an node in the DOM tree for a given XPath expression or a CSS selector.
first ( string $expression, string $type = Query::TYPE_CSS, boolean $wrapElement = true ) : Element | DOMElement | null Searches for an node in the DOM tree and returns first element or null.
firstChild ( ) : Element | null
getAttribute ( string $name, string $default = null ) : string | null Access to the element's attributes.
getDocument ( ) : Document | null Returns the document associated with this node.
getLineNo ( ) : integer Get line number for a node.
getNode ( ) : DOMNode Get current \DOMNode instance.
has ( string $expression, string $type = Query::TYPE_CSS ) : boolean Checks the existence of the node.
hasAttribute ( string $name ) : boolean Determine if an attribute exists on the element.
html ( integer $options = LIBXML_NOEMPTYTAG ) : string Dumps the node into a string using HTML formatting.
innerHtml ( integer $options = LIBXML_NOEMPTYTAG, sting $delimiter = '' ) : string Dumps the node descendants into a string using HTML formatting.
is ( Element | DOMNode $node ) : boolean Indicates if two nodes are the same node.
isCommentNode ( ) : boolean Returns true if current node is comment.
isTextNode ( ) : boolean Returns true if current node is text.
lastChild ( ) : Element | null
matches ( string $selector, boolean $strict = false ) : boolean Checks that the node matches selector.
nextSibling ( ) : Element | null
parent ( ) : Element | Document | null
previousSibling ( ) : Element | null
remove ( ) : Element Removes child from list of children.
removeAttribute ( string $name ) : Element Unset an attribute on the element.
replace ( $newNode, boolean $clone = true ) : Element Replaces a child.
setAttribute ( string $name, string $value ) : Element Set an attribute on the element.
setInnerHtml ( string $html ) : Element Sets inner HTML.
setValue ( string $value ) : Element Set the value of this node.
text ( ) : string Get the text content of this node and its descendants.
toDocument ( string $encoding = 'UTF-8' ) : Document Get the DOM document with the current element.
xml ( integer $options ) : string Dumps the node into a string using XML formatting.
xpath ( string $expression, boolean $wrapElement = true ) : Element[] | DOMElement[] Searches for an node in the DOM tree for a given XPath expression.

보호된 메소드들

메소드 설명
setNode ( DOMElement | DOMText | DOMComment $node ) : Element Sets current \DOMNode instance.

메소드 상세

__construct() 공개 메소드

Constructor.
public __construct ( DOMNode | string $name, string $value = null, array $attributes = [] )
$name DOMNode | string The tag name of the element
$value string The value of the element
$attributes array The attributes of the element

__get() 공개 메소드

Dynamically access the element's attributes.
public __get ( string $name ) : string | null
$name string The attribute name
리턴 string | null

__invoke() 공개 메소드

Searches for an node in the DOM tree for a given XPath expression or a CSS selector.
public __invoke ( string $expression, string $type = Query::TYPE_CSS, boolean $wrapElement = true ) : Element[] | DOMElement[]
$expression string XPath expression or a CSS selector
$type string The type of the expression
$wrapElement boolean Returns array of \DiDom\Element if true, otherwise array of \DOMElement
리턴 Element[] | DOMElement[]

__isset() 공개 메소드

Determine if an attribute exists on the element.
public __isset ( string $name ) : boolean
$name string The attribute name
리턴 boolean

__set() 공개 메소드

Dynamically set an attribute on the element.
public __set ( string $name, mixed $value ) : Element
$name string The attribute name
$value mixed The attribute value
리턴 Element

__toString() 공개 메소드

Convert the element to its string representation.
public __toString ( ) : string
리턴 string

__unset() 공개 메소드

Unset an attribute on the model.
public __unset ( string $name )
$name string The attribute name

appendChild() 공개 메소드

Adds new child at the end of the children.
public appendChild ( Element | DOMNode | array $nodes ) : Element
$nodes Element | DOMNode | array The appended child
리턴 Element

attr() 공개 메소드

Alias for getAttribute and setAttribute methods.
public attr ( string $name, string $value = null ) : string | null | Element
$name string The attribute name
$value string The attribute value or null if the attribute does not exist
리턴 string | null | Element

attributes() 공개 메소드

Returns the node attributes or null, if it is not DOMElement.
public attributes ( ) : array | null
리턴 array | null

child() 공개 메소드

public child ( $index ) : Element | null
리턴 Element | null

children() 공개 메소드

public children ( ) : Element[]
리턴 Element[]

cloneNode() 공개 메소드

Clones a node.
public cloneNode ( boolean $deep = true ) : Element
$deep boolean Indicates whether to copy all descendant nodes
리턴 Element The cloned node

closest() 공개 메소드

Returns first parent node matches passed selector.
public closest ( string $selector, boolean $strict = false ) : Element | null
$selector string
$strict boolean
리턴 Element | null

count() 공개 메소드

Counts nodes for a given XPath expression or a CSS selector.
public count ( string $expression, string $type = Query::TYPE_CSS ) : integer
$expression string XPath expression or CSS selector
$type string The type of the expression
리턴 integer

create() 공개 정적인 메소드

Create new element.
public static create ( DOMNode | string $name, string $value = null, array $attributes = [] ) : Element
$name DOMNode | string The tag name of the element
$value string The value of the element
$attributes array The attributes of the element
리턴 Element

createBySelector() 공개 정적인 메소드

Create new element node by CSS selector.
public static createBySelector ( string $selector, string $value = null, array $attributes = [] ) : Element
$selector string
$value string
$attributes array
리턴 Element

find() 공개 메소드

Searches for an node in the DOM tree for a given XPath expression or a CSS selector.
public find ( string $expression, string $type = Query::TYPE_CSS, boolean $wrapElement = true ) : Element[] | DOMElement[]
$expression string XPath expression or a CSS selector
$type string The type of the expression
$wrapElement boolean Returns array of \DiDom\Element if true, otherwise array of \DOMElement
리턴 Element[] | DOMElement[]

first() 공개 메소드

Searches for an node in the DOM tree and returns first element or null.
public first ( string $expression, string $type = Query::TYPE_CSS, boolean $wrapElement = true ) : Element | DOMElement | null
$expression string XPath expression or a CSS selector
$type string The type of the expression
$wrapElement boolean Returns \DiDom\Element if true, otherwise \DOMElement
리턴 Element | DOMElement | null

firstChild() 공개 메소드

public firstChild ( ) : Element | null
리턴 Element | null

getAttribute() 공개 메소드

Access to the element's attributes.
public getAttribute ( string $name, string $default = null ) : string | null
$name string The attribute name
$default string The value returned if the attribute does not exist
리턴 string | null The value of the attribute or null if attribute does not exist

getDocument() 공개 메소드

Returns the document associated with this node.
public getDocument ( ) : Document | null
리턴 Document | null

getLineNo() 공개 메소드

Get line number for a node.
public getLineNo ( ) : integer
리턴 integer

getNode() 공개 메소드

Get current \DOMNode instance.
public getNode ( ) : DOMNode
리턴 DOMNode

has() 공개 메소드

Checks the existence of the node.
public has ( string $expression, string $type = Query::TYPE_CSS ) : boolean
$expression string XPath expression or CSS selector
$type string The type of the expression
리턴 boolean

hasAttribute() 공개 메소드

Determine if an attribute exists on the element.
public hasAttribute ( string $name ) : boolean
$name string The attribute name
리턴 boolean

html() 공개 메소드

Dumps the node into a string using HTML formatting.
public html ( integer $options = LIBXML_NOEMPTYTAG ) : string
$options integer Additional options
리턴 string The node HTML

innerHtml() 공개 메소드

Dumps the node descendants into a string using HTML formatting.
public innerHtml ( integer $options = LIBXML_NOEMPTYTAG, sting $delimiter = '' ) : string
$options integer Additional options
$delimiter sting
리턴 string

is() 공개 메소드

Indicates if two nodes are the same node.
public is ( Element | DOMNode $node ) : boolean
$node Element | DOMNode
리턴 boolean

isCommentNode() 공개 메소드

Returns true if current node is comment.
public isCommentNode ( ) : boolean
리턴 boolean

isTextNode() 공개 메소드

Returns true if current node is text.
public isTextNode ( ) : boolean
리턴 boolean

lastChild() 공개 메소드

public lastChild ( ) : Element | null
리턴 Element | null

matches() 공개 메소드

Checks that the node matches selector.
public matches ( string $selector, boolean $strict = false ) : boolean
$selector string CSS selector
$strict boolean
리턴 boolean

nextSibling() 공개 메소드

public nextSibling ( ) : Element | null
리턴 Element | null

parent() 공개 메소드

public parent ( ) : Element | Document | null
리턴 Element | Document | null

previousSibling() 공개 메소드

public previousSibling ( ) : Element | null
리턴 Element | null

remove() 공개 메소드

Removes child from list of children.
public remove ( ) : Element
리턴 Element the node that has been removed

removeAttribute() 공개 메소드

Unset an attribute on the element.
public removeAttribute ( string $name ) : Element
$name string The attribute name
리턴 Element

replace() 공개 메소드

Replaces a child.
public replace ( $newNode, boolean $clone = true ) : Element
$clone boolean Clone the node if true, otherwise move it
리턴 Element The node that has been replaced

setAttribute() 공개 메소드

Set an attribute on the element.
public setAttribute ( string $name, string $value ) : Element
$name string The attribute name
$value string The attribute value
리턴 Element

setInnerHtml() 공개 메소드

Sets inner HTML.
public setInnerHtml ( string $html ) : Element
$html string
리턴 Element

setNode() 보호된 메소드

Sets current \DOMNode instance.
protected setNode ( DOMElement | DOMText | DOMComment $node ) : Element
$node DOMElement | DOMText | DOMComment
리턴 Element

setValue() 공개 메소드

Set the value of this node.
public setValue ( string $value ) : Element
$value string The new value of the node
리턴 Element

text() 공개 메소드

Get the text content of this node and its descendants.
public text ( ) : string
리턴 string The node value

toDocument() 공개 메소드

Get the DOM document with the current element.
public toDocument ( string $encoding = 'UTF-8' ) : Document
$encoding string The document encoding
리턴 Document

xml() 공개 메소드

Dumps the node into a string using XML formatting.
public xml ( integer $options ) : string
$options integer Additional options
리턴 string The node XML

xpath() 공개 메소드

Searches for an node in the DOM tree for a given XPath expression.
public xpath ( string $expression, boolean $wrapElement = true ) : Element[] | DOMElement[]
$expression string XPath expression
$wrapElement boolean Returns array of \DiDom\Element if true, otherwise array of \DOMElement
리턴 Element[] | DOMElement[]

프로퍼티 상세

$node 보호되어 있는 프로퍼티

The DOM element instance.
protected DOMNode; $node
리턴 DOMNode;