PHP Class FluentDOM\Element

Inheritance: extends DOMElement, implements ArrayAccess, implements Countable, implements IteratorAggregate, implements FluentDOM\Node\ChildNode, implements Node\NonDocumentTypeChildNode, implements FluentDOM\Node\ParentNode, use trait FluentDOM\Node\ChildNode\Implementation, use trait FluentDOM\Node\NonDocumentTypeChildNode\Implementation, use trait FluentDOM\Node\ParentNode\Implementation, use trait Node\QuerySelector\Implementation, use trait FluentDOM\Node\StringCast, use trait FluentDOM\Node\Xpath, use trait FluentDOM\HHVM\Properties
Datei anzeigen Open project: fluentdom/fluentdom Class Usage Examples

Public Methods

Method Description
__get ( $name )
__set ( $name, $value )
append ( mixed $value ) Append a value to the element node
appendElement ( string $name, string $content = '', array $attributes = NULL ) : Element Append an child element
appendToParentNode ( )
appendXml ( string $xmlFragment ) Append an xml fragment to the element node
applyNamespaces ( null | string | array $prefixes = NULL ) Sets all namespaces registered on the document as xmlns attributes on the element.
count ( ) : integer Return child node count
find ( string $expression ) : Query Put the current node into a FluentDOM\Query and call find() on it.
getAttribute ( string $name ) : string Get an attribute value
getAttributeNode ( string $name ) : Attribute | DOMAttr Get an attribute value
getElementsByTagName ( string $name ) : DOMNodeList Allow getElementsByTagName to use the defined namespaces.
getIterator ( ) : ElementIterator Return Iterator for child nodes.
hasAttribute ( string $name ) : boolean Validate if an attribute exists
offsetExists ( integer | string $offset ) : boolean Validate if an offset exists. If a integer is provided it will check for a child node, if a string is provided for an attribute.
offsetGet ( integer | string $offset ) : DOMNode | mixed | string Get a child node by its numeric index, or an attribute by its name.
offsetSet ( integer | string $offset, DOMNode | string $value ) : DOMAttr | DOMNode | void
offsetUnset ( integer | string $offset ) Remove a child node using its index or an attribute node using its name.
removeAttribute ( string $name ) : boolean Set an attribute on an element
saveHtml ( ) : string save the element node as HTML
saveXml ( ) : string save the element node as XML
saveXmlFragment ( ) : string Save the child nodes of this element as an XML fragment.
setAttribute ( string $name, string $value ) : DOMAttr Set an attribute on an element
setIdAttribute ( string $name, boolean $isId ) Set an attribute on an element

Private Methods

Method Description
getDocument ( ) : Document A getter for the owner document
isAttributeOffset ( mixed $offset ) : boolean Attribute offsets are strings that can not only contains digits.
isCurrentNamespace ( string $prefix, string $namespace ) : boolean Return true if the provided namespace is the same as the one on the element
isNodeOffset ( mixed $offset ) : boolean Node offsets are integers, or strings containing only digits.
resolveTagName ( string $name ) : string[] Resolves a provided tag name into namespace and local name

Method Details

__get() public method

public __get ( $name )

__set() public method

public __set ( $name, $value )

append() public method

The value can be: - a node (automatically imported and cloned) - an object implementing FluentDOM\Appendable (method appendTo()) - a scalar or object castable to string (adds a text node) - an array (sets attributes)
public append ( mixed $value )
$value mixed

appendElement() public method

Append an child element
public appendElement ( string $name, string $content = '', array $attributes = NULL ) : Element
$name string
$content string
$attributes array
return Element

appendToParentNode() public method

public appendToParentNode ( )

appendXml() public method

Append an xml fragment to the element node
public appendXml ( string $xmlFragment )
$xmlFragment string

applyNamespaces() public method

Sets all namespaces registered on the document as xmlns attributes on the element.
public applyNamespaces ( null | string | array $prefixes = NULL )
$prefixes null | string | array

count() public method

Return child node count
public count ( ) : integer
return integer

find() public method

Put the current node into a FluentDOM\Query and call find() on it.
public find ( string $expression ) : Query
$expression string
return Query

getAttribute() public method

Get an attribute value
public getAttribute ( string $name ) : string
$name string
return string

getAttributeNode() public method

Get an attribute value
public getAttributeNode ( string $name ) : Attribute | DOMAttr
$name string
return Attribute | DOMAttr

getElementsByTagName() public method

Allow getElementsByTagName to use the defined namespaces.
public getElementsByTagName ( string $name ) : DOMNodeList
$name string
return DOMNodeList

getIterator() public method

Return Iterator for child nodes.
public getIterator ( ) : ElementIterator
return FluentDOM\Iterators\ElementIterator

hasAttribute() public method

Validate if an attribute exists
public hasAttribute ( string $name ) : boolean
$name string
return boolean

offsetExists() public method

Validate if an offset exists. If a integer is provided it will check for a child node, if a string is provided for an attribute.
public offsetExists ( integer | string $offset ) : boolean
$offset integer | string
return boolean

offsetGet() public method

Get a child node by its numeric index, or an attribute by its name.
public offsetGet ( integer | string $offset ) : DOMNode | mixed | string
$offset integer | string
return DOMNode | mixed | string

offsetSet() public method

public offsetSet ( integer | string $offset, DOMNode | string $value ) : DOMAttr | DOMNode | void
$offset integer | string
$value DOMNode | string
return DOMAttr | DOMNode | void

offsetUnset() public method

Remove a child node using its index or an attribute node using its name.
public offsetUnset ( integer | string $offset )
$offset integer | string

removeAttribute() public method

Set an attribute on an element
public removeAttribute ( string $name ) : boolean
$name string
return boolean

saveHtml() public method

save the element node as HTML
public saveHtml ( ) : string
return string

saveXml() public method

save the element node as XML
public saveXml ( ) : string
return string

saveXmlFragment() public method

Save the child nodes of this element as an XML fragment.
public saveXmlFragment ( ) : string
return string

setAttribute() public method

Set an attribute on an element
public setAttribute ( string $name, string $value ) : DOMAttr
$name string
$value string
return DOMAttr

setIdAttribute() public method

Set an attribute on an element
public setIdAttribute ( string $name, boolean $isId )
$name string
$isId boolean