PHP Class FluentDOM\Document

Inheritance: extends DOMDocument, implements FluentDOM\Node\ParentNode, use trait FluentDOM\Node\ParentNode\Properties, use trait Node\QuerySelector\Implementation, use trait FluentDOM\Node\Xpath
Afficher le fichier Open project: fluentdom/fluentdom Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( string $version = '1.0', string $encoding = 'UTF-8' )
appendElement ( string $name, string $content = '', array $attributes = NULL ) : Element Overload appendElement to add a text content and attributes directly.
createAttribute ( string $name, string | null $value = NULL ) : DOMAttr If here is a ':' in the attribute name, consider it a namespace prefix registered on the document.
createElement ( string $name, string | array $content = NULL, array $attributes = NULL ) : Element If here is a ':' in the element name, consider it a namespace prefix registered on the document.
createElementNS ( string $namespaceURI, string $qualifiedName, string | null $content = null ) : Element
find ( string $expression ) : Query Put the document node into a FluentDOM\Query and call find() on it.
getElementsByTagName ( string $name ) : DOMNodeList Allow getElementsByTagName to use the defined namespaces.
getNamespace ( string $prefix ) : string Get the namespace for a given prefix
namespaces ( array $namespaces = NULL ) : array Get set the namespaces registered for the document object.
registerNamespace ( string $prefix, string $namespace ) register a namespace prefix for the document, it will be used in createElement and setAttribute
saveHTML ( DOMNode | DOMNodeList | null $context = NULL ) : string Allow to save HTML fragments, providing a node list
toHtml ( DOMNode | DOMNodeList | null $context = NULL ) : string Allow to save HTML fragments, providing a node list.
toXml ( DOMNode | DOMNodeList | null $context = NULL, integer $options ) : string Allow to save XML fragments, providing a node list
xpath ( ) : Xpath Generate an xpath instance for the document, if the document of the xpath instance does not match the document, regenerate it.

Private Methods

Méthode Description
appendAttributes ( DOMElement $node, string | array | null $content = NULL, array $attributes = NULL )
appendContent ( DOMElement $node, string | array | null $content = NULL )
validatePrefix ( string $prefix ) : string

Method Details

__construct() public méthode

public __construct ( string $version = '1.0', string $encoding = 'UTF-8' )
$version string
$encoding string

appendElement() public méthode

Overload appendElement to add a text content and attributes directly.
public appendElement ( string $name, string $content = '', array $attributes = NULL ) : Element
$name string
$content string
$attributes array
Résultat Element

createAttribute() public méthode

Allow to add a attribute value directly.
public createAttribute ( string $name, string | null $value = NULL ) : DOMAttr
$name string
$value string | null
Résultat DOMAttr

createElement() public méthode

Allow to add a text content and attributes directly. If $content is an array, the $content argument will be merged with the $attributes argument.
public createElement ( string $name, string | array $content = NULL, array $attributes = NULL ) : Element
$name string
$content string | array
$attributes array
Résultat Element

createElementNS() public méthode

public createElementNS ( string $namespaceURI, string $qualifiedName, string | null $content = null ) : Element
$namespaceURI string
$qualifiedName string
$content string | null
Résultat Element

find() public méthode

Put the document node into a FluentDOM\Query and call find() on it.
public find ( string $expression ) : Query
$expression string
Résultat Query

getElementsByTagName() public méthode

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

getNamespace() public méthode

Get the namespace for a given prefix
public getNamespace ( string $prefix ) : string
$prefix string
Résultat string

namespaces() public méthode

If the argument is provided ALL namespaces will be replaced.
public namespaces ( array $namespaces = NULL ) : array
$namespaces array
Résultat array

registerNamespace() public méthode

register a namespace prefix for the document, it will be used in createElement and setAttribute
public registerNamespace ( string $prefix, string $namespace )
$prefix string
$namespace string

saveHTML() public méthode

Allow to save HTML fragments, providing a node list
public saveHTML ( DOMNode | DOMNodeList | null $context = NULL ) : string
$context DOMNode | DOMNodeList | null
Résultat string

toHtml() public méthode

This is an alias for the extended saveHTML() method. Make it consistent with toXml()
public toHtml ( DOMNode | DOMNodeList | null $context = NULL ) : string
$context DOMNode | DOMNodeList | null
Résultat string

toXml() public méthode

Overloading saveXML() with a removed type hint triggers an E_STRICT error, so we the function needs a new name. :-(
public toXml ( DOMNode | DOMNodeList | null $context = NULL, integer $options ) : string
$context DOMNode | DOMNodeList | null
$options integer
Résultat string

xpath() public méthode

Generate an xpath instance for the document, if the document of the xpath instance does not match the document, regenerate it.
public xpath ( ) : Xpath
Résultat Xpath