-
Notifications
You must be signed in to change notification settings - Fork 20
Xpath
FluentDOM\Xpath
extends DOMAttr.
This property enables or disables the automatic namespace registration for the evaluate()/query()
. This can be overwritten by the third argument of evaluate()/query()
. This will currently not work with HHVM.
Fetch nodes or scalar values from the DOM using Xpath expression. 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.
Triggers an E_USER_DEPRECATED
error. FluentDOM\Xpath::query()
only supports xpath expressions that return a DOMNodeList. FluentDOM\Xpath::evaluate()
returns a DOMNodelist or a scalar value depending on the expression.
Calls the FluentDOM\Xpath::evaluate()
and return the first matched node or NULL.
$document = new FluentDOM\DOM\Document();
$document->loadXml('<xml>Hello World</xml>');
$xpath = new FluentDOM\Xpath($document);
echo $xpath->firstOf('//xml');
Quote a value to use it in an xpath expression. 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.
$value = "World";
$document = new FluentDOM\DOM\Document();
$document->loadXml('<xml>Hello World</xml>');
$xpath = new FluentDOM\Xpath($document);
echo $xpath->evaluate(
'string(//xml[contains(., '.$xpath->quote($value).')])'
);
- Home
- Getting Started
- Tasks
- Plugins
- Functions
- Lists
- Creator (5.1)
- CSS Selectors
- Convertors
- Loaders
- Serializers (5.1)
- Transformers (5.1)
- Extended DOM
- XMLReader (6.1)
- XMLWriter (6.1)
- Interfaces