DOMXPath::registerPhpFunctionsRegister PHP functions as XPath functions Description
public void DOMXPath::registerPhpFunctions
([ mixed
$restrict
] )This method enables the ability to use PHP functions within XPath expressions. Parameters
Return ValuesNo value is returned. ExamplesThe following examples use book.xml which contains the following:
Example #1 book.xml <?xml version="1.0" encoding="UTF-8"?> <books> <book> <title>PHP Basics</title> <author>Jim Smith</author> <author>Jane Smith</author> </book> <book> <title>PHP Secrets</title> <author>Jenny Smythe</author> </book> <book> <title>XML basics</title> <author>Joe Black</author> </book> </books>
Example #2 DOMXPath::registerPHPFunctions with php:functionString
<?php The above example will output something similar to: Found 2 books starting with 'PHP': PHP Basics by Jim Smith PHP Secrets by Jenny Smythe
Example #3 DOMXPath::registerPHPFunctions with php:function
<?php The above example will output something similar to: Books with multiple authors: PHP Basics See Also
|