PHP Class FluentDOM\Xpath

Inheritance: extends DOMXPath
Exibir arquivo Open project: fluentdom/fluentdom Class Usage Examples

Public Methods

Method Description
__construct ( DOMDocument $dom ) HHVM and some old PHP versions do not have a $document property by default Add it is added if it was not found after executing parent constructor.
__get ( string $name ) : mixed
__invoke ( string $expression, DOMNode $contextNode = NULL ) : string | float | boolean | DOMNodeList Fetch nodes or scalar values from the DOM using Xpath expression.
__isset ( string $name ) : boolean
__set ( string $name, mixed $value ) : mixed
__unset ( string $name )
evaluate ( string $expression, DOMNode $contextNode = NULL, null | boolean $registerNodeNS = NULL ) : string | float | boolean | DOMNodeList Fetch nodes or scalar values from the DOM using Xpath expression.
firstOf ( string $expression, DOMNode $contextNode = NULL, null | boolean $registerNodeNS = NULL ) : DOMNode | null Returns the first node matched by the expression or NULL.
query ( string $expression, DOMNode $contextNode = NULL, null | boolean $registerNodeNS = NULL ) : DOMNodeList Fetch nodes defined by the xpath expression and return the node list.
quote ( string $string ) : string Quote (and escape) a value to use it in an xpath expression.
registerNamespace ( string $prefix, string $namespace ) : boolean If the owner document is a FluentDOM\Document register the namespace on the document object, too.

Method Details

__construct() public method

HHVM and some old PHP versions do not have a $document property by default Add it is added if it was not found after executing parent constructor.
public __construct ( DOMDocument $dom )
$dom DOMDocument

__get() public method

public __get ( string $name ) : mixed
$name string
return mixed

__invoke() public method

Fetch nodes or scalar values from the DOM using Xpath expression.
public __invoke ( string $expression, DOMNode $contextNode = NULL ) : string | float | boolean | DOMNodeList
$expression string
$contextNode DOMNode
return string | float | boolean | DOMNodeList

__isset() public method

public __isset ( string $name ) : boolean
$name string
return boolean

__set() public method

public __set ( string $name, mixed $value ) : mixed
$name string
$value mixed
return mixed

__unset() public method

public __unset ( string $name )
$name string

evaluate() public method

The main difference to DOMXpath::evaluate() is the handling of the third argument. Namespace registration can be changed using the property and is disabled by default.
public evaluate ( string $expression, DOMNode $contextNode = NULL, null | boolean $registerNodeNS = NULL ) : string | float | boolean | DOMNodeList
$expression string
$contextNode DOMNode
$registerNodeNS null | boolean
return string | float | boolean | DOMNodeList

firstOf() public method

Returns the first node matched by the expression or NULL.
public firstOf ( string $expression, DOMNode $contextNode = NULL, null | boolean $registerNodeNS = NULL ) : DOMNode | null
$expression string
$contextNode DOMNode
$registerNodeNS null | boolean
return DOMNode | null

query() public method

This method is deprecated and only implemented for BC. So this method calls evaluate().
Deprecation:
public query ( string $expression, DOMNode $contextNode = NULL, null | boolean $registerNodeNS = NULL ) : DOMNodeList
$expression string
$contextNode DOMNode
$registerNodeNS null | boolean
return DOMNodeList

quote() public method

Xpath 1 does not have a way to escape quotes, it only allows double quotes in single quoted literals and single quotes in double quoted literals. If both quotes are included in the string, the method will generate a concat() function call.
public quote ( string $string ) : string
$string string
return string

registerNamespace() public method

If the owner document is a FluentDOM\Document register the namespace on the document object, too.
public registerNamespace ( string $prefix, string $namespace ) : boolean
$prefix string
$namespace string
return boolean