version 3.3Php.XPath documentation |
---|
Documentation for the XPath.class.php file
Php.XPath by S.Blum / N.Swinson / D.Allen / (P.Mehl).
+======================================================================================================+ | A php class for searching an XML document using XPath, and making modifications using a DOM | style API. Does not require the DOM XML PHP library. | +======================================================================================================+ | What Is XPath: | -------------- | - "What SQL is for a relational database, XPath is for an XML document." -- Sam Blum | - "The primary purpose of XPath is to address parts of an XML document. In support of this | primary purpose, it also provides basic facilities for manipulting it." -- W3C | | XPath in action and a very nice intro is under: | http://www.zvon.org/xxl/XPathTutorial/General/examples.html | Specs Can be found under: | http://www.w3.org/TR/xpath W3C XPath Recommendation | http://www.w3.org/TR/xpath20 W3C XPath Recommendation | | NOTE: Most of the XPath-spec has been realized, but not all. Usually this should not be | problem as the missing part is either rarely used or it's simpler to do with PHP itself. +------------------------------------------------------------------------------------------------------+ | Requires PHP version 4.0.5 and up +------------------------------------------------------------------------------------------------------+ | Main Active Authors: | -------------------- | Nigel Swinson <nigelswinson@users.sourceforge.net> | Started around 2001-07, saved phpxml from near death and renamed to Php.XPath | Restructured XPath code to stay in line with XPath spec. | Sam Blum <bs_php@infeer.com> | Started around 2001-09 1st major restruct (V2.0) and testbench initiator. | 2nd (V3.0) major rewrite in 2002-02 | Daniel Allen <bigredlinux@yahoo.com> | Started around 2001-10 working to make Php.XPath adhere to specs | Main Former Author: Michael P. Mehl <mpm@phpxml.org> | Inital creator of V 1.0. Stoped activities around 2001-03 +------------------------------------------------------------------------------------------------------+ | Code Structure: | --------------_ | The class is split into 3 main objects. To keep usability easy all 3 | objects are in this file (but may be split in 3 file in future). | +-------------+ | | XPathBase | XPathBase holds general and debugging functions. | +------+------+ | v | +-------------+ XPathEngine is the implementation of the W3C XPath spec. It contains the | | XPathEngine | XML-import (parser), -export and can handle xPathQueries. It's a fully | +------+------+ functional class but has no functions to modify the XML-document (see following). | v | +-------------+ | | XPath | XPath extends the functionality with actions to modify the XML-document. | +-------------+ We tryed to implement a DOM - like interface. +------------------------------------------------------------------------------------------------------+ | Usage: | ------ | Scroll to the end of this php file and you will find a short sample code to get you started +------------------------------------------------------------------------------------------------------+ | Glossary: | --------- | To understand how to use the functions and to pass the right parameters, read following: | | Document: (full node tree, XML-tree) | After a XML-source has been imported and parsed, it's stored as a tree of nodes sometimes | refered to as 'document'. | | AbsoluteXPath: (xPath, xPathSet) | A absolute XPath is a string. It 'points' to *one* node in the XML-document. We use the | term 'absolute' to emphasise that it is not an xPath-query (see xPathQuery). A valid xPath | has the form like '/AAA[1]/BBB[2]/CCC[1]'. Usually functions that require a node (see Node) | will also accept an abs. XPath. | | Node: (node, nodeSet, node-tree) | Some funtions require or return a node (or a whole node-tree). Nodes are only used with the | XPath-interface and have an internal structure. Every node in a XML document has a unique | corresponding abs. xPath. That's why public functions that accept a node, will usually also | accept a abs. xPath (a string) 'pointing' to an existing node (see absolutXPath). | | XPathQuery: (xquery, query) | A xPath-query is a string that is matched against the XML-document. The result of the match | is a xPathSet (vector of xPath's). It's always possible to pass a single absoluteXPath | instead of a xPath-query. A valid xPathQuery could look like this: | '//XXX/*[contains(., "foo")]/..' (See the link in 'What Is XPath' to learn more). | | +------------------------------------------------------------------------------------------------------+ | Internals: | ---------- | - The Node Tree | ------------- | A central role of the package is how the XML-data is stored. The whole data is in a node-tree. | A node can be seen as the equvalent to a tag in the XML soure with some extra info. | For instance the following XML | <AAA foo="x">***<BBB/><CCC/>**<BBB/>*</AAA> | Would produce folowing node-tree: | 'super-root' <-- $nodeRoot (Very handy) | | | 'depth' 0 AAA[1] <-- top node. The 'textParts' of this node would be | / | \ 'textParts' => array('***','','**','*') | 'depth' 1 BBB[1] CCC[1] BBB[2] (NOTE: Is always size of child nodes+1) | - The Node | -------- | The node itself is an structure desiged mainly to be used in connection with the interface of PHP.XPath. | That means it's possible for functions to return a sub-node-tree that can be used as input of an other | PHP.XPath function. | | The main structure of a node is: | $node = array( | 'name' => '', # The tag name. E.g. In <FOO bar="aaa"/> it would be 'FOO' | 'attributes' => array(), # The attributes of the tag E.g. In <FOO bar="aaa"/> it would be array('bar'=>'aaa') | 'textParts' => array(), # Array of text parts surrounding the children E.g. <FOO>aa<A>bb<B/>cc</A>dd</FOO> -> array('aa','bb','cc','dd') | 'childNodes' => array(), # Array of refences (pointers) to child nodes. | | For optimisation reasions some additional data is stored in the node too: | 'parentNode' => NULL # Reference (pointer) to the parent node (or NULL if it's 'super root') | 'depth' => 0, # The tag depth (or tree level) starting with the root tag at 0. | 'pos' => 0, # Is the zero-based position this node has in the parent's 'childNodes'-list. | 'contextPos' => 1, # Is the one-based position this node has by counting the siblings tags (tags with same name) | 'xpath' => '' # Is the abs. XPath to this node. | | - The NodeIndex | ------------- | Every node in the tree has an absolute XPath. E.g '/AAA[1]/BBB[2]' the $nodeIndex is a hash array | to all the nodes in the node-tree. The key used is the absolute XPath (a string). | +------------------------------------------------------------------------------------------------------+ | License: | -------- | The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); | you may not use this file except in compliance with the License. You may obtain a copy of the | License at http://www.mozilla.org/MPL/ | | Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY | OF ANY KIND, either express or implied. See the License for the specific language governing | rights and limitations under the License. | | The Original Code is <phpXML/>. | | The Initial Developer of the Original Code is Michael P. Mehl. Portions created by Michael | P. Mehl are Copyright (C) 2001 Michael P. Mehl. All Rights Reserved. | | Contributor(s): N.Swinson / S.Blum / D.Allen | | Alternatively, the contents of this file may be used under the terms of either of the GNU | General Public License Version 2 or later (the "GPL"), or the GNU Lesser General Public | License Version 2.1 or later (the "LGPL"), in which case the provisions of the GPL or the | LGPL License are applicable instead of those above. If you wish to allow use of your version | of this file only under the terms of the GPL or the LGPL License and not to allow others to | use your version of this file under the MPL, indicate your decision by deleting the | provisions above and replace them with the notice and other provisions required by the | GPL or the LGPL License. If you do not delete the provisions above, a recipient may use | your version of this file under either the MPL, the GPL or the LGPL License. | +======================================================================================================+
Public functions of XPath
Public base class members inherited from XPathEngine
Public base class members inherited from XPathBase
You really shouldn't be raking about in these functions, as you should only be using the public interface. But if you need more control, then these are the internal functions that you can use if you want to get your hands really dirty.
Method Details: XPathBase
function XPathBase()
Constructor
Line:
Defined on line 180
Method Details: reset
function reset()
Resets the object so it's able to take a new xml sting/file
Constructing objects is slow. If you can, reuse ones that you have used already by using this reset() function.Line:
Defined on line 211
Method Details: setVerbose
function setVerbose($levelOfVerbosity = 1)
Alter the verbose (error) level reporting.
Pass an int. >0 to turn on, 0 to turn off. The higher the number, the higher the level of verbosity. By default, the class has a verbose level of 1.Parameter:
- int $levelOfVerbosity
default is 1 = on
Line:
Defined on line 515
Method Details: getLastError
function getLastError()
Returns the last occured error message.
Return Value:
string (may be empty if there was no error at all)
Similar Functions:
_setLastError(), _lastError
Line:
Defined on line 534
Method Details: _bracketsCheck
function _bracketsCheck($term)
This method checks the right amount and match of brackets
Parameter:
- string $term
String in which is checked.
Return Value:
boolTRUE: OK / FALSE: KO
Line:
Defined on line 225
Method Details: _searchString
function _searchString($term, $expression)
Looks for a string within another string -- BUT the search-string must be located *outside* of any brackets.
This method looks for a string within another string. Brackets in the string the method is looking through will be respected, which means that only if the string the method is looking for is located outside of brackets, the search will be successful.Parameter:
- string $term
String in which the search shall take place.
- string $expression
String that should be searched.
Return Value:
intThis method returns -1 if no string was found, otherwise the offset at which the string was found.
Line:
Defined on line 282
Method Details: _bracketExplode
function _bracketExplode($separator, $term)
Split a string by a searator-string -- BUT the separator-string must be located *outside* of any brackets.
Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by the string separator.Parameter:
- string $separator
String that should be searched.
- string $term
String in which the search shall take place.
Return Value:
arraysee above
Line:
Defined on line 314
Method Details: _getEndGroups
function _getEndGroups($string, $open='[', $close=']')
Split a string at it's groups, ie bracketed expressions
Returns an array of strings, when concatenated together would produce the original string. ie a(b)cde(f)(g) would map to: array ('a', '(b)', cde', '(f)', '(g)')Parameter:
- string $string
The string to process
- string $open
The substring for the open of a group
- string $close
The substring for the close of a group
Return Value:
arrayThe parsed string, see above
Line:
Defined on line 392
Method Details: _prestr
function _prestr(&$string, $delimiter, $offset=0)
Retrieves a substring before a delimiter.
This method retrieves everything from a string before a given delimiter, not including the delimiter.Parameter:
- string $string
String, from which the substring should be extracted.
- string $delimiter
String containing the delimiter to use.
Return Value:
stringSubstring from the original string before the delimiter.
Similar Functions:
_afterstr()
Line:
Defined on line 478
Method Details: _afterstr
function _afterstr($string, $delimiter, $offset=0)
Retrieves a substring after a delimiter.
This method retrieves everything from a string after a given delimiter, not including the delimiter.Parameter:
- string $string
String, from which the substring should be extracted.
- string $delimiter
String containing the delimiter to use.
Return Value:
stringSubstring from the original string after the delimiter.
Similar Functions:
_prestr()
Line:
Defined on line 496
Method Details: _setLastError
function _setLastError($message='', $line='-', $file='-')
Creates a textual error message and sets it.
example: 'XPath error in THIS_FILE_NAME:LINE. Message: YOUR_MESSAGE'; I don't think the message should include any markup because not everyone wants to debug into the browser window. You should call _displayError() rather than _setLastError() if you would like the message, dependant on their verbose settings, echoed to the screen.Parameter:
- string $message
a textual error message default is ''
- int $line
the line number where the error occured, use __LINE__
Similar Functions:
getLastError()
Line:
Defined on line 553
Method Details: _displayError
function _displayError($message, $lineNumber='-', $file='-', $terminate=TRUE)
Displays an error message.
This method displays an error messages depending on the users verbose settings and sets the last error message. If also possibly stops the execution of the script. ### Terminate should not be allowed --fab. Should it?? N.S.Parameter:
- string $message
Error message to be displayed.
- int $lineNumber
line number given by __LINE__
- bool $terminate
(default TURE) End the execution of this script.
Line:
Defined on line 570
Method Details: _displayMessage
function _displayMessage($message, $lineNumber='-', $file='-')
Displays a diagnostic message
This method displays an error messagesParameter:
- string $message
Error message to be displayed.
- int $lineNumber
line number given by __LINE__
Line:
Defined on line 587
Method Details: _beginDebugFunction
function _beginDebugFunction($functionName)
Called to begin the debug run of a function.
This method starts a <DIV><PRE> tag so that the entry to this function is clear to the debugging user. Call _closeDebugFunction() at the end of the function to create a clean box round the function call.Parameter:
- string $functionName
the name of the function we are beginning to debug
Return Value:
arraythe output from the microtime() function.
Author:
Sam Blum <bs_php@infeer.com>
Similar Functions:
_closeDebugFunction()
Line:
Defined on line 606
Method Details: _closeDebugFunction
function _closeDebugFunction($aStartTime, $returnValue = "")
Called to end the debug run of a function.
This method ends a <DIV><PRE> block and reports the time since $aStartTime is clear to the debugging user.Parameter:
- array $aStartTime
the time that the function call was started.
- mixed $return_value
the return value from the function call that we are debugging
Author:
Nigel Swinson <nigelswinson@users.sourceforge.net>
Line:
Defined on line 632
Method Details: _profileFunction
function _profileFunction($aStartTime, $alertString)
Call to return time since start of function for Profiling
Parameter:
- array $aStartTime
the time that the function call was started.
- string $alertString
the string to describe what has just finished happening
Line:
Defined on line 657
Method Details: _printContext
function _printContext($context)
Echo an XPath context for diagnostic purposes
Parameter:
- array $context
An XPath context
Line:
Defined on line 670
Method Details: _treeDump
function _treeDump($node, $indent = '')
This is a debug helper function. It dumps the node-tree as HTML
*QUICK AND DIRTY*. Needs some polishing.Parameter:
- array $node
A node
- string $indent
(optional, default=''). For internal recursive calls.
Line:
Defined on line 682
The XPathEngine class extends the XPathBase class.
You really shouldn't be raking about in these functions, as you should only be using the public interface. But if you need more control, then these are the internal functions that you can use if you want to get your hands really dirty.
Method Details: XPathEngine
function XPathEngine($userXmlOptions=array())
Constructor
Optionally you may call this constructor with the XML-filename to parse and the XML option vector. Each of the entries in the option vector will be passed to xml_parser_set_option(). A option vector sample: $xmlOpt = array(XML_OPTION_CASE_FOLDING => FALSE, XML_OPTION_SKIP_WHITE => TRUE);Parameter:
- array $userXmlOptions
(optional) Vector of (<optionID>=><value>, <optionID>=><value>, ...). See PHP's xml_parser_set_option() docu for a list of possible options.
Similar Functions:
importFromFile(), importFromString(), setXmlOptions()
Line:
Defined on line 817
Method Details: reset
function reset()
Resets the object so it's able to take a new xml sting/file
Constructing objects is slow. If you can, reuse ones that you have used already by using this reset() function.Line:
Defined on line 837
Method Details: getProperties
function getProperties($param=NULL)
Returns the property/ies you want.
if $param is not given, all properties will be returned in a hash.Parameter:
- string $param
the property you want the value of, or NULL for all the properties
Return Value:
mixedstring OR hash of all params, or NULL on an unknown parameter.
Line:
Defined on line 862
Method Details: setXmlOption
function setXmlOption($optionID, $value)
Set an xml_parser_set_option()
Parameter:
- int $optionID
The option ID (e.g. XML_OPTION_SKIP_WHITE)
- int $value
The option value.
Similar Functions:
XML parser functions in PHP doc
Line:
Defined on line 883
Method Details: setXmlOptions
function setXmlOptions($userXmlOptions=array())
Sets a number of xml_parser_set_option()s
Parameter:
- array $userXmlOptions
An array of parser options.
Similar Functions:
setXmlOption
Line:
Defined on line 894
Method Details: setCaseFolding
function setCaseFolding($onOff=TRUE)
Alternative way to control whether case-folding is enabled for this XML parser.
Short cut to setXmlOptions(XML_OPTION_CASE_FOLDING, TRUE/FALSE) When it comes to XML, case-folding simply means uppercasing all tag- and attribute-names (NOT the content) if set to TRUE. Note if you have this option set, then your XPath queries will also be case folded for you.Parameter:
- bool $onOff
(default TRUE)
Similar Functions:
XML parser functions in PHP doc
Line:
Defined on line 914
Method Details: setSkipWhiteSpaces
function setSkipWhiteSpaces($onOff=TRUE)
Alternative way to control whether skip-white-spaces is enabled for this XML parser.
Short cut to setXmlOptions(XML_OPTION_SKIP_WHITE, TRUE/FALSE) When it comes to XML, skip-white-spaces will trim the tag content. An XML file with no whitespace will be faster to process, but will make your data less human readable when you come to write it out. Running with this option on will slow the class down, so if you want to speed up your XML, then run it through once skipping white-spaces, then write out the new version of your XML without whitespace, then use the new XML file with skip whitespaces turned off.Parameter:
- bool $onOff
(default TRUE)
Similar Functions:
XML parser functions in PHP doc
Line:
Defined on line 935
Method Details: getNode
function &getNode($absoluteXPath='')
Get the node defined by the $absoluteXPath.
Parameter:
- string $absoluteXPath
(optional, default is 'super-root') xpath to the node.
Return Value:
arrayThe node, or FALSE if the node wasn't found.
Line:
Defined on line 945
Method Details: wholeText
function &wholeText($absoluteXPath, $textPartNr=NULL)
Get a the content of a node text part or node attribute.
If the absolute Xpath references an attribute (Xpath ends with @ or attribute::), then the text value of that node-attribute is returned. Otherwise the Xpath is referencing a text part of the node. This can be either a direct reference to a text part (Xpath ends with text()[<nr>]) or indirect reference (a simple abs. Xpath to a node). 1) Direct Reference (xpath ends with text()[<part-number>]): If the 'part-number' is omitted, the first text-part is assumed; starting by 1. Negative numbers are allowed, where -1 is the last text-part a.s.o. 2) Indirect Reference (a simple abs. Xpath to a node): Default is to return the *whole text*; that is the concated text-parts of the matching node. (NOTE that only in this case you'll only get a copy and changes to the returned value wounld have no effect). Optionally you may pass a parameter $textPartNr to define the text-part you want; starting by 1. Negative numbers are allowed, where -1 is the last text-part a.s.o. NOTE I : The returned value can be fetched by reference E.g. $text =& wholeText(). If you wish to modify the text. NOTE II: text-part numbers out of range will return FALSE SIDENOTE:The function name is a suggestion from W3C in the XPath specification level 3.Parameter:
- string $absoluteXPath
xpath to the node (See above).
- int $textPartNr
If referring to a node, specifies which text part to query.
Return Value:
&stringA *reference* to the text if the node that the other parameters describe or FALSE if the node is not found.
Line:
Defined on line 980
Method Details: exportAsHtml
function exportAsHtml($absoluteXPath='', $hilightXpathList=array())
Returns the containing XML as marked up HTML with specified nodes hi-lighted
Parameter:
- string $absoluteXPath
The address of the node you would like to export. If empty the whole document will be exported.
- array $hilighXpathList
A list of nodes that you would like to highlight
Return Value:
mixedThe Xml document marked up as HTML so that it can be viewed in a browser, including any XML headers. FALSE on error.
Similar Functions:
_export()
Line:
Defined on line 1071
Method Details: exportAsXml
function exportAsXml($absoluteXPath='', $xmlHeader=NULL)
Given a context this function returns the containing XML
Parameter:
- string $absoluteXPath
The address of the node you would like to export. If empty the whole document will be exported.
- array $xmlHeader
The string that you would like to appear before the XML content. ie before the <root></root>. If you do not specify this argument, the xmlHeader that was found in the parsed xml file will be used instead.
Return Value:
mixedThe Xml fragment/document, suitable for writing out to an .xml file or as part of a larger xml file, or FALSE on error.
Similar Functions:
_export()
Line:
Defined on line 1091
Method Details: exportToFile
function exportToFile($fileName, $absoluteXPath='', $xmlHeader=NULL)
Generates a XML string with the content of the current document and writes it to a file.
Per default includes a <?xml ...> tag at the start of the data too.Parameter:
- string $absoluteXPath
The path to the parent node you want(see text above)
- array $xmlHeader
The string that you would like to appear before the XML content. ie before the <root></root>. If you do not specify this argument, the xmlHeader that was found in the parsed xml file will be used instead.
Return Value:
stringThe returned string contains well-formed XML data or FALSE on error.
Similar Functions:
exportAsXml(), exportAsHtml()
Line:
Defined on line 1111
Method Details: importFromFile
function importFromFile($fileName)
Reads a file or URL and parses the XML data.
Parse the XML source and (upon success) store the information into an internal structure.Parameter:
- string $fileName
Path and name (or URL) of the file to be read and parsed.
Return Value:
boolTRUE on success, FALSE on failure (check getLastError())
Similar Functions:
importFromString(), getLastError(),
Line:
Defined on line 1499
Method Details: importFromString
function importFromString($xmlString, $absoluteParentPath = '')
Reads a string and parses the XML data.
Parse the XML source and (upon success) store the information into an internal structure. If a parent xpath is given this means that XML data is to be *appended* to that parent. ### If a function uses setLastError(), then say in the function header that getLastError() is useful.Parameter:
- string $xmlString
Name of the string to be read and parsed.
- string $absoluteParentPath
Node to append data too (see above)
Return Value:
boolTRUE on success, FALSE on failure (check getLastError())
Line:
Defined on line 1564
Method Details: reindexNodeTree
function reindexNodeTree()
Update nodeIndex and every node of the node-tree.
Call after you have finished any tree modifications other wise a match with an xPathQuery will produce wrong results. The $this->nodeIndex[] is recreated and every nodes optimization data is updated. The optimization data is all the data that is duplicate information, would just take longer to find. Child nodes with value NULL are removed from the tree. By default the modification functions in this component will automatically re-index the nodes in the tree. Sometimes this is not the behaver you want. To surpress the reindex, set the functions $autoReindex to FALSE and call reindexNodeTree() at the end of your changes. This sometimes leads to better code (and less CPU overhead). Sample: ======= Given the xml is <AAA><B/>.<B/>.<B/></AAA> | Goal is <AAA>.<B/>.</AAA> (Delete B[1] and B[3]) $xPathSet = $xPath->match('//B'); # Will result in array('/AAA[1]/B[1]', '/AAA[1]/B[2]', '/AAA[1]/B[3]'); Three ways to do it. 1) Top-Down (with auto reindexing) - Safe, Slow and you get easily mix up with the the changing node index removeChild('/AAA[1]/B[1]'); // B[1] removed, thus all B[n] become B[n-1] !! removeChild('/AAA[1]/B[2]'); // Now remove B[2] (That originaly was B[3]) 2) Bottom-Up (with auto reindexing) - Safe, Slow and the changing node index (caused by auto-reindex) can be ignored. for ($i=sizeOf($xPathSet)-1; $i>=0; $i--) { if ($i==1) continue; removeChild($xPathSet[$i]); } 3) // Top-down (with *NO* auto reindexing) - Fast, Safe as long as you call reindexNodeTree() foreach($xPathSet as $xPath) { // Specify no reindexing if ($xPath == $xPathSet[1]) continue; removeChild($xPath, $autoReindex=FALSE); // The object is now in a slightly inconsistent state. } // Finally do the reindex and the object is consistent again reindexNodeTree();Return Value:
boolTRUE on success, FALSE otherwise.
Similar Functions:
_recursiveReindexNodeTree()
Line:
Defined on line 2009
Method Details: cloneNode
function &cloneNode($node, $recursive=FALSE)
Clone a node and it's child nodes.
NOTE: If the node has children you *MUST* use the reference operator! E.g. $clonedNode =& cloneNode($node); Otherwise the children will not point back to the parent, they will point back to your temporary variable instead.Parameter:
- mixed $node
Either a node (hash array) or an abs. Xpath to a node in the current doc
Return Value:
&arrayA node and it's child nodes.
Line:
Defined on line 2118
Method Details: match
function match($xPathQuery, $baseXPath='')
Matches (evaluates) an XPath query
This method tries to evaluate an XPath query by parsing it. A XML source must have been imported before this method is able to work.Parameter:
- string $xPathQuery
XPath query to be evaluated.
- string $baseXPath
(default is super-root) XPath query to a single document node, from which the XPath query should start evaluating.
Return Value:
mixedThe result of the XPath expression. Either: node-set (an ordered collection of nodes without duplicates) boolean (true or false) number (a floating-point number) string (a sequence of UCS characters)
Line:
Defined on line 2193
Method Details: evaluate
function evaluate($xPathQuery, $baseXPath='')
Alias for the match function
Similar Functions:
match()
Line:
Defined on line 2252
Method Details: equalNodes
function equalNodes($node1, $node2)
Compare two nodes to see if they are equal (point to the same node in the doc)
2 nodes are considered equal if the absolute XPath is equal.Parameter:
- mixed $node1
Either an absolute XPath to an node OR a real tree-node (hash-array)
- mixed $node2
Either an absolute XPath to an node OR a real tree-node (hash-array)
Return Value:
boolTRUE if equal (see text above), FALSE if not (and on error).
Line:
Defined on line 4284
Method Details: getNodePath
function getNodePath($node)
Get the absolute XPath of a node that is in a document tree.
Parameter:
- array $node
A real tree-node (hash-array)
Return Value:
stringThe string path to the node or FALSE on error.
Line:
Defined on line 4296
Method Details: getParentXPath
function getParentXPath($absoluteXPath)
Retrieves the absolute parent XPath query.
The parents stored in the tree are only relative parents...but all the parent information is stored in the XPath query itself...so instead we use a function to extract the parent from the absolute Xpath queryParameter:
- string $childPath
String containing an absolute XPath query
Return Value:
stringreturns the absolute XPath of the parent
Line:
Defined on line 4323
Method Details: hasChildNodes
function hasChildNodes($absoluteXPath)
Returns TRUE if the given node has child nodes below it
Parameter:
- string $absoluteXPath
full path of the potential parent node
Return Value:
boolTRUE if this node exists and has a child, FALSE otherwise
Line:
Defined on line 4338
Method Details: _export
function _export($absoluteXPath='', $xmlHeader=NULL, $hilightXpathList='')
Generates a XML string with the content of the current document.
This is the start for extracting the XML-data from the node-tree. We do some preperations and then call _InternalExport() to fetch the main XML-data. You optionally may pass xpath to any node that will then be used as top node, to extract XML-parts of the document. Default is '', meaning to extract the whole document. You also may pass a 'xmlHeader' (usually something like <?xml version="1.0"? > that will overwrite any other 'xmlHeader', if there was one in the original source. If there wasn't one in the original source, and you still don't specify one, then it will use a default of <?xml version="1.0"? > Finaly, when exporting to HTML, you may pass a vector xPaths you want to hi-light. The hi-lighted tags and attributes will receive a nice color. NOTE I : The output can have 2 formats: a) If "skip white spaces" is/was set. (Not Recommended - slower) The output is formatted by adding indenting and carriage returns. b) If "skip white spaces" is/was *NOT* set. 'as is'. No formatting is done. The output should the same as the the original parsed XML source.Parameter:
- string $absoluteXPath
(optional, default is root) The node we choose as top-node
- string $xmlHeader
(optional) content before <root/> (see text above)
- array $hilightXpath
(optional) a vector of xPaths to nodes we wat to hi-light (see text above)
Return Value:
mixedThe xml string, or FALSE on error.
Line:
Defined on line 1175
Method Details: _InternalExport
function _InternalExport($node)
Export the xml document starting at the named node.
Parameter:
- node $node
The node we have to start exporting from
Return Value:
stringThe string representation of the node.
Line:
Defined on line 1248
Method Details: _handleStartElement
function _handleStartElement($parser, $nodeName, $attributes)
Handles opening XML tags while parsing.
While parsing a XML document for each opening tag this method is called. It'll add the tag found to the tree of document nodes.Parameter:
- int $parser
Handler for accessing the current XML parser.
- string $name
Name of the opening tag found in the document.
- array $attributes
Associative array containing a list of all attributes of the tag found in the document.
Similar Functions:
_handleEndElement(), _handleCharacterData()
Line:
Defined on line 1704
Method Details: _handleEndElement
function _handleEndElement($parser, $name)
Handles closing XML tags while parsing.
While parsing a XML document for each closing tag this method is called.Parameter:
- int $parser
Handler for accessing the current XML parser.
- string $name
Name of the closing tag found in the document.
Similar Functions:
_handleStartElement(), _handleCharacterData()
Line:
Defined on line 1762
Method Details: _handleCharacterData
function _handleCharacterData($parser, $text)
Handles character data while parsing.
While parsing a XML document for each character data this method is called. It'll add the character data to the document tree.Parameter:
- int $parser
Handler for accessing the current XML parser.
- string $text
Character data found in the document.
Similar Functions:
_handleStartElement(), _handleEndElement()
Line:
Defined on line 1812
Method Details: _handleDefaultData
function _handleDefaultData($parser, $text)
Default handler for the XML parser.
While parsing a XML document for string not caught by one of the other handler functions, we end up here.Parameter:
- int $parser
Handler for accessing the current XML parser.
- string $text
Character data found in the document.
Similar Functions:
_handleStartElement(), _handleEndElement()
Line:
Defined on line 1845
Method Details: _handlePI
function _handlePI($parser, $target, $data)
Handles processing instruction (PI)
A processing instruction has the following format: <? target data ? > e.g. <? dtd version="1.0" ? > Currently I have no bether idea as to left it 'as is' and treat the PI data as normal text (and adding the surrounding PI-tags <? ? >).Parameter:
- int $parser
Handler for accessing the current XML parser.
- string $target
Name of the PI target. E.g. XML, PHP, DTD, ...
- string $data
Associative array containing a list of
Similar Functions:
PHP's manual "xml_set_processing_instruction_handler"
Line:
Defined on line 1873
Method Details: _createSuperRoot
function _createSuperRoot()
Creates a super root node.
Line:
Defined on line 1887
Method Details: _internalAppendChild
function _internalAppendChild($stackParentIndex, $nodeName)
Adds a new node to the XML document tree during xml parsing.
This method adds a new node to the tree of nodes of the XML document being handled by this class. The new node is created according to the parameters passed to this method. This method is a much watered down version of appendChild(), used in parsing an xml file only. It is assumed that adding starts with root and progresses through the document in parse order. New nodes must have a corresponding parent. And once we have read the </> tag for the element we will never need to add any more data to that node. Otherwise the add will be ignored or fail. The function is faciliated by a nodeStack, which is an array of nodes that we have yet to close.Parameter:
- int $stackParentIndex
The index into the nodeStack[] of the parent node to which the new node should be added as a child. *READONLY*
- string $nodeName
Name of the new node. *READONLY*
Return Value:
boolTRUE if we successfully added a new child to the node stack at index $stackParentIndex + 1, FALSE on error.
Line:
Defined on line 1919
Method Details: _recursiveReindexNodeTree
function _recursiveReindexNodeTree($absoluteParentPath)
Here's where the work is done for reindexing (see reindexNodeTree)
Parameter:
- string $absoluteParentPath
the xPath to the parent node
Return Value:
boolTRUE on success, FALSE otherwise.
Similar Functions:
reindexNodeTree()
Line:
Defined on line 2025
Method Details: __sleep
function __sleep()
PHP cals this function when you call PHP's serialize.
It prevents cyclic referencing, which is why print_r() of an XPath object doesn't work.Line:
Defined on line 2153
Method Details: __wakeup
function __wakeup()
PHP cals this function when you call PHP's unserialize.
It reindexes the node-treeLine:
Defined on line 2168
Method Details: _removeLiterals
function _removeLiterals($xPathQuery)
Parse out the literals of an XPath expression.
Instead of doing a full lexical parse, we parse out the literal strings, and then Treat the sections of the string either as parts of XPath or literal strings. So this function replaces each literal it finds with a literal reference, and then inserts the reference into an array of strings that we can access. The literals can be accessed later from the literals associative array. Example: XPathExpr = /AAA[@CCC = "hello"]/BBB[DDD = 'world'] => literals: array("hello", "world") return value: /AAA[@CCC = $1]/BBB[DDD = $2] Note: This does not interfere with the VariableReference syntactical element, as these elements must not start with a number.Parameter:
- string $xPathQuery
XPath expression to be processed
Return Value:
stringThe XPath expression without the literals.
Line:
Defined on line 2277
Method Details: _asLiteral
function _asLiteral($string)
Returns the given string as a literal reference.
Parameter:
- string $string
The string that we are processing
Return Value:
mixedThe literal string. FALSE if the string isn't a literal reference.
Line:
Defined on line 2312
Method Details: _addLiteral
function _addLiteral($string)
Adds a literal to our array of literals
In order to make sure we don't interpret literal strings as XPath expressions, we have to encode literal strings so that we know that they are not XPaths.Parameter:
- string $string
The literal string that we need to store for future access
Return Value:
mixedA reference string to this literal.
Line:
Defined on line 2341
Method Details: _evaluateExpr
function _evaluateExpr($xPathQuery, $context)
Internal recursive evaluate an-XPath-expression function.
$this->evaluate() is the entry point and does some inits, while this function is called recursive internaly for every sub-xPath expresion we find.Parameter:
- string $xPathQuery
XPath query to be evaluated.
- array $context
An associative array the describes the context from which to evaluate the XPath Expr. Contains three members: 'nodePath' => The absolute XPath expression to the context node 'size' => The context size 'pos' => The context position
Return Value:
mixedThe result of the XPath expression. Either: node-set (an ordered collection of nodes without duplicates) boolean (true or false) number (a floating-point number) string (a sequence of UCS characters)
Similar Functions:
evaluate()
Line:
Defined on line 2368
Method Details: _evaluatePathExpr
function _evaluatePathExpr($PathExpr, $context)
Internal recursive evaluate an Path expression.
Parameter:
- string $PathExpr
PathExpr syntactical element
- array $context
The context from which to evaluate
Return Value:
mixedThe result of the XPath expression. Either: node-set (an ordered collection of nodes without duplicates) boolean (true or false) number (a floating-point number) string (a sequence of UCS characters)
Similar Functions:
evaluate()
Line:
Defined on line 2781
Method Details: _sortByDocOrder
function _sortByDocOrder($xPathSet)
Sort an xPathSet by doc order.
Parameter:
- array $xPathSet
Array of full paths to nodes that need to be sorted
Return Value:
arrayArray containing the same contents as $xPathSet, but with the contents in doc order
Line:
Defined on line 2839
Method Details: _evaluateStep
function _evaluateStep($steps, $context)
Evaluate a step from a XPathQuery expression at a specific contextPath.
Steps are the arguments of a XPathQuery when divided by a '/'. A contextPath is a absolute XPath (or vector of XPaths) to a starting node(s) from which the step should be evaluated.Parameter:
- array $steps
Vector containing the remaining steps of the current XPathQuery expression.
- array $context
The context from which to evaluate
Return Value:
arrayVector of absolute XPath's as a result of the step evaluation. The results will not necessarily be in doc order
Similar Functions:
evaluate()
Line:
Defined on line 2937
Method Details: _checkPredicates
function _checkPredicates($xPathSet, $predicates)
Checks whether a node matches predicates.
This method checks whether a list of nodes passed to this method match a given list of predicates.Parameter:
- array $xPathSet
Array of full paths of all nodes to be tested.
- array $predicates
Array of predicates to use.
Return Value:
arrayVector of absolute XPath's that match the given predicates.
Similar Functions:
_evaluateStep()
Line:
Defined on line 3034
Method Details: _evaluateFunction
function _evaluateFunction($function, $arguments, $context)
Evaluates an XPath function
This method evaluates a given XPath function with its arguments on a specific node of the document.Parameter:
- string $function
Name of the function to be evaluated.
- string $arguments
String containing the arguments being passed to the function.
- array $context
The context from which to evaluate
Return Value:
mixedThis method returns the result of the evaluation of the function. Depending on the function the type of the return value can be different.
Similar Functions:
evaluate()
Line:
Defined on line 3130
Method Details: _checkNodeTest
function _checkNodeTest($contextPath, $nodeTest)
Checks whether a node matches a node-test.
This method checks whether a node in the document matches a given node-test. A node test is something like text(), node(), or an element name.Parameter:
- string $contextPath
Full xpath of the node, which should be tested for matching the node-test.
- string $nodeTest
String containing the node-test for the node.
Return Value:
booleanThis method returns TRUE if the node matches the node-test, otherwise FALSE.
Similar Functions:
evaluate()
Line:
Defined on line 3188
Method Details: _getAxis
function _getAxis($step, $context)
Retrieves axis information from an XPath query step.
This method tries to extract the name of the axis and its node-test from a given step of an XPath query at a given node.Parameter:
- string $step
String containing a step of an XPath query.
- array $context
The context from which to evaluate
Return Value:
arrayContains information about the axis found in the step.
Similar Functions:
_evaluateStep()
Line:
Defined on line 3262
Method Details: _handleAxis_child
function _handleAxis_child($axis, $contextPath)
Handles the XPath child axis.
This method handles the XPath child axis. It essentially filters out the children to match the name specified after the '/'.Parameter:
- array $axis
Array containing information about the axis.
- string $contextPath
xpath to starting node from which the axis should be processed.
Return Value:
arrayA vector containing all nodes that were found, during the evaluation of the axis.
Similar Functions:
evaluate()
Line:
Defined on line 3402
Method Details: _handleAxis_parent
function _handleAxis_parent($axis, $contextPath)
Handles the XPath parent axis.
Parameter:
- array $axis
Array containing information about the axis.
- string $contextPath
xpath to starting node from which the axis should be processed.
Return Value:
arrayA vector containing all nodes that were found, during the evaluation of the axis.
Similar Functions:
evaluate()
Line:
Defined on line 3449
Method Details: _handleAxis_attribute
function _handleAxis_attribute($axis, $contextPath)
Handles the XPath attribute axis.
Parameter:
- array $axis
Array containing information about the axis.
- string $contextPath
xpath to starting node from which the axis should be processed.
Return Value:
arrayA vector containing all nodes that were found, during the evaluation of the axis.
Similar Functions:
evaluate()
Line:
Defined on line 3468
Method Details: _handleAxis_self
function _handleAxis_self($axis, $contextPath)
Handles the XPath self axis.
Parameter:
- array $axis
Array containing information about the axis.
- string $contextPath
xpath to starting node from which the axis should be processed.
Return Value:
arrayA vector containing all nodes that were found, during the evaluation of the axis.
Similar Functions:
evaluate()
Line:
Defined on line 3493
Method Details: _handleAxis_descendant
function _handleAxis_descendant($axis, $contextPath)
Handles the XPath descendant axis.
Parameter:
- array $axis
Array containing information about the axis.
- string $contextPath
xpath to starting node from which the axis should be processed.
Return Value:
arrayA vector containing all nodes that were found, during the evaluation of the axis.
Similar Functions:
evaluate()
Line:
Defined on line 3511
Method Details: _handleAxis_ancestor
function _handleAxis_ancestor($axis, $contextPath)
Handles the XPath ancestor axis.
Parameter:
- array $axis
Array containing information about the axis.
- string $contextPath
xpath to starting node from which the axis should be processed.
Return Value:
arrayA vector containing all nodes that were found, during the evaluation of the axis.
Similar Functions:
evaluate()
Line:
Defined on line 3539
Method Details: _handleAxis_namespace
function _handleAxis_namespace($axis, $contextPath)
Handles the XPath namespace axis.
Parameter:
- array $axis
Array containing information about the axis.
- string $contextPath
xpath to starting node from which the axis should be processed.
Return Value:
arrayA vector containing all nodes that were found, during the evaluation of the axis.
Similar Functions:
evaluate()
Line:
Defined on line 3564
Method Details: _handleAxis_following
function _handleAxis_following($axis, $contextPath)
Handles the XPath following axis.
Parameter:
- array $axis
Array containing information about the axis.
- string $contextPath
xpath to starting node from which the axis should be processed.
Return Value:
arrayA vector containing all nodes that were found, during the evaluation of the axis.
Similar Functions:
evaluate()
Line:
Defined on line 3576
Method Details: _handleAxis_preceding
function _handleAxis_preceding($axis, $contextPath)
Handles the XPath preceding axis.
Parameter:
- array $axis
Array containing information about the axis.
- string $contextPath
xpath to starting node from which the axis should be processed.
Return Value:
arrayA vector containing all nodes that were found, during the evaluation of the axis.
Similar Functions:
evaluate()
Line:
Defined on line 3611
Method Details: _handleAxis_following_sibling
function _handleAxis_following_sibling($axis, $contextPath)
Handles the XPath following-sibling axis.
Parameter:
- array $axis
Array containing information about the axis.
- string $contextPath
xpath to starting node from which the axis should be processed.
Return Value:
arrayA vector containing all nodes that were found, during the evaluation of the axis.
Similar Functions:
evaluate()
Line:
Defined on line 3641
Method Details: _handleAxis_preceding_sibling
function _handleAxis_preceding_sibling($axis, $contextPath)
Handles the XPath preceding-sibling axis.
Parameter:
- array $axis
Array containing information about the axis.
- string $contextPath
xpath to starting node from which the axis should be processed.
Return Value:
arrayA vector containing all nodes that were found, during the evaluation of the axis.
Similar Functions:
evaluate()
Line:
Defined on line 3677
Method Details: _handleAxis_descendant_or_self
function _handleAxis_descendant_or_self($axis, $contextPath)
Handles the XPath descendant-or-self axis.
Parameter:
- array $axis
Array containing information about the axis.
- string $contextPath
xpath to starting node from which the axis should be processed.
Return Value:
arrayA vector containing all nodes that were found, during the evaluation of the axis.
Similar Functions:
evaluate()
Line:
Defined on line 3707
Method Details: _handleAxis_ancestor_or_self
function _handleAxis_ancestor_or_self ( $axis, $contextPath)
Handles the XPath ancestor-or-self axis.
This method handles the XPath ancestor-or-self axis.Parameter:
- array $axis
Array containing information about the axis.
- string $contextPath
xpath to starting node from which the axis should be processed.
Return Value:
arrayA vector containing all nodes that were found, during the evaluation of the axis.
Similar Functions:
evaluate()
Line:
Defined on line 3728
Method Details: _handleFunction_last
function _handleFunction_last($arguments, $context)
Handles the XPath function last.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 3752
Method Details: _handleFunction_position
function _handleFunction_position($arguments, $context)
Handles the XPath function position.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 3764
Method Details: _handleFunction_count
function _handleFunction_count($arguments, $context)
Handles the XPath function count.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 3776
Method Details: _handleFunction_id
function _handleFunction_id($arguments, $context)
Handles the XPath function id.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 3789
Method Details: _handleFunction_name
function _handleFunction_name($arguments, $context)
Handles the XPath function name.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 3814
Method Details: _handleFunction_string
function _handleFunction_string($arguments, $context)
Handles the XPath function string.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 3837
Method Details: _handleFunction_concat
function _handleFunction_concat($arguments, $context)
Handles the XPath function concat.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 3876
Method Details: _handleFunction_starts_with
function _handleFunction_starts_with($arguments, $context)
Handles the XPath function starts-with.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 3898
Method Details: _handleFunction_contains
function _handleFunction_contains($arguments, $context)
Handles the XPath function contains.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 3917
Method Details: _handleFunction_substring_before
function _handleFunction_substring_before($arguments, $context)
Handles the XPath function substring-before.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 3945
Method Details: _handleFunction_substring_after
function _handleFunction_substring_after($arguments, $context)
Handles the XPath function substring-after.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 3964
Method Details: _handleFunction_substring
function _handleFunction_substring($arguments, $context)
Handles the XPath function substring.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 3983
Method Details: _handleFunction_string_length
function _handleFunction_string_length($arguments, $context)
Handles the XPath function string-length.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 4008
Method Details: _handleFunction_normalize_space
function _handleFunction_normalize_space($arguments, $context)
Handles the XPath function normalize-space.
The normalize-space function returns the argument string with whitespace normalized by stripping leading and trailing whitespace and replacing sequences of whitespace characters by a single space. If the argument is omitted, it defaults to the context node converted to a string, in other words the string-value of the context nodeParameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
strig trimed string
Similar Functions:
evaluate()
Line:
Defined on line 4029
Method Details: _handleFunction_translate
function _handleFunction_translate($arguments, $context)
Handles the XPath function translate.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 4047
Method Details: _handleFunction_boolean
function _handleFunction_boolean($arguments, $context)
Handles the XPath function boolean.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 4067
Method Details: _handleFunction_not
function _handleFunction_not($arguments, $context)
Handles the XPath function not.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 4112
Method Details: _handleFunction_true
function _handleFunction_true($arguments, $context)
Handles the XPath function TRUE.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 4127
Method Details: _handleFunction_false
function _handleFunction_false($arguments, $context)
Handles the XPath function FALSE.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 4139
Method Details: _handleFunction_lang
function _handleFunction_lang($arguments, $context)
Handles the XPath function lang.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 4151
Method Details: _handleFunction_number
function _handleFunction_number($arguments, $context)
Handles the XPath function number.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 4173
Method Details: _handleFunction_sum
function _handleFunction_sum($arguments, $context)
Handles the XPath function sum.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 4206
Method Details: _handleFunction_floor
function _handleFunction_floor($arguments, $context)
Handles the XPath function floor.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 4231
Method Details: _handleFunction_ceiling
function _handleFunction_ceiling($arguments, $context)
Handles the XPath function ceiling.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 4247
Method Details: _handleFunction_round
function _handleFunction_round($arguments, $context)
Handles the XPath function round.
Parameter:
- string $arguments
String containing the arguments that were passed to the function.
- array $context
The context from which to evaluate the function
Return Value:
mixedDepending on the type of function being processed
Similar Functions:
evaluate()
Line:
Defined on line 4263
Method Details: _translateAmpersand
function _translateAmpersand($xmlSource, $reverse=FALSE)
Translate all ampersands to it's literal entities '&' and back.
I wasn't aware of this problem at first but it's important to understand why we do this. At first you must know: a) PHP's XML parser *translates* all entities to the equivalent char E.g. < is returned as '<' b) PHP's XML parser (in V 4.1.0) has problems with most *literal* entities! The only one's that are recognized are &, < > and ". *ALL* others (like © a.s.o.) cause an XML_ERROR_UNDEFINED_ENTITY error. I reported this as bug at http://bugs.php.net/bug.php?id=15092 (It turned out not to be a 'real' bug, but one of those nice W3C-spec things). Forget position b) now. It's just for info. Because the way we will solve a) will also solve b) too. THE PROBLEM To understand the problem, here a sample: Given is the following XML: "<AAA> < > </AAA>" Try to parse it and PHP's XML parser will fail with a XML_ERROR_UNDEFINED_ENTITY becaus of the unknown litteral-entity ' '. (The numeric equivalent ' ' would work though). Next try is to use the numeric equivalent 160 for ' ', thus "<AAA> <   > </AAA>" The data we receive in the tag <AAA> is " < > ". So we get the *translated entities* and NOT the 3 entities <   >. Thus, we will not even notice that there were entities at all! In *most* cases we're not able to tell if the data was given as entity or as 'normal' char. E.g. When receiving a quote or a single space were not able to tell if it was given as 'normal' char or as or ". Thus we loose the entity-information of the XML-data! THE SOLUTION The better solution is to keep the data 'as is' by replacing the '&' before parsing begins. E.g. Taking the original input from above, this would result in "<AAA> &lt; &nbsp; &gt; </AAA>" The data we receive now for the tag <AAA> is " < > ". and that's what we want. The bad thing is, that a global replace will also replace data in section that are NOT translated by the PHP XML-parser. That is comments (<!-- -->), IP-sections (stuff between <? ? >) and CDATA-block too. So all data comming from those sections must be reversed. This is done during the XML parse phase. So: a) Replacement of all '&' in the XML-source. b) All data that is not char-data or in CDATA-block have to be reversed during the XML-parse phase.Parameter:
- string $xmlSource
The XML string
Return Value:
stringThe XML string with translated ampersands.
Line:
Defined on line 4383
The XPath class extends the XPathEngine class.
You really shouldn't be raking about in these functions, as you should only be using the public interface. But if you need more control, then these are the internal functions that you can use if you want to get your hands really dirty.
Method Details: XPath
function XPath($fileName='', $userXmlOptions=array())
Constructor of the class
Optionally you may call this constructor with the XML-filename to parse and the XML option vector. A option vector sample: $xmlOpt = array(XML_OPTION_CASE_FOLDING => FALSE, XML_OPTION_SKIP_WHITE => TRUE);Parameter:
- array $userXmlOptions
(optional) Vector of (<optionID>=><value>, <optionID>=><value>, ...)
- string $fileName
(optional) Filename of XML file to load from. It is recommended that you call importFromFile() instead as you will get an error code. If the import fails, the object will be set to FALSE.
Similar Functions:
parent::XPathEngine()
Line:
Defined on line 4416
Method Details: reset
function reset()
Resets the object so it's able to take a new xml sting/file
Constructing objects is slow. If you can, reuse ones that you have used already by using this reset() function.Line:
Defined on line 4432
Method Details: setModMatch
function setModMatch($modMatch = XPATH_QUERYHIT_ALL)
Resolves and xPathQuery array depending on the property['modMatch']
Most of the modification functions of XPath will also accept a xPathQuery (instead of an absolute Xpath). The only problem is that the query could match more the one node. The question is, if the none, the fist or all nodes are to be modified. The behaver can be set with setModMatch()Parameter:
- int $modMatch
One of the following: - XPATH_QUERYHIT_ALL (default) - XPATH_QUERYHIT_FIRST - XPATH_QUERYHIT_UNIQUE // If the query matches more then one node.
Similar Functions:
_resolveXPathQuery()
Line:
Defined on line 4455
Method Details: nodeName
function nodeName($xPathQuery)
Retrieves the name(s) of a node or a group of document nodes.
This method retrieves the names of a group of document nodes specified in the argument. So if the argument was '/A[1]/B[2]' then it would return 'B' if the node did exist in the tree.Parameter:
- mixed $xPathQuery
Array or single full document path(s) of the node(s), from which the names should be retrieved.
Return Value:
mixedArray or single string of the names of the specified nodes, or just the individual name. If the node did not exist, then returns FALSE.
Line:
Defined on line 4484
Method Details: removeChild
function removeChild($xPathQuery, $autoReindex=TRUE)
Removes a node from the XML document.
This method removes a node from the tree of nodes of the XML document. If the node is a document node, all children of the node and its character data will be removed. If the node is an attribute node, only this attribute will be removed, the node to which the attribute belongs as well as its children will remain unmodified. NOTE: When passing a xpath-query instead of an abs. Xpath. Depending on setModMatch() one, none or multiple nodes are affected.Parameter:
- string $xPathQuery
xpath to the node (See note above).
- bool $autoReindex
(optional, default=TRUE) Reindex the document to reflect the changes. A performance helper. See reindexNodeTree()
Return Value:
boolTRUE on success, FALSE on error;
Similar Functions:
setModMatch(), reindexNodeTree()
Line:
Defined on line 4525
Method Details: replaceChildByData
function replaceChildByData($xPathQuery, $data, $autoReindex=TRUE)
Replace a node with any data string. The $data is taken 1:1.
This function will delete the node you define by $absoluteXPath (plus it's sub-nodes) and substitute it by the string $text. Often used to push in not well formed HTML. WARNING: The $data is taken 1:1. You are in charge that the data you enter is valid XML if you intend to export and import the content again. NOTE: When passing a xpath-query instead of an abs. Xpath. Depending on setModMatch() one, none or multiple nodes are affected.Parameter:
- string $xPathQuery
xpath to the node (See note above).
- string $data
String containing the content to be set. *READONLY*
- bool $autoReindex
(optional, default=TRUE) Reindex the document to reflect the changes. A performance helper. See reindexNodeTree()
Return Value:
boolTRUE on success, FALSE on error;
Similar Functions:
setModMatch(), replaceChild(), reindexNodeTree()
Line:
Defined on line 4587
Method Details: replaceChild
function &replaceChild($xPathQuery, $node, $autoReindex=TRUE)
Replace the node(s) that matches the xQuery with the passed node (or passed node-tree)
If the passed node is a string it's assumed to be XML and replaceChildByXml() will be called. NOTE: When passing a xpath-query instead of an abs. Xpath. Depending on setModMatch() one, none or multiple nodes are affected.Parameter:
- string $xPathQuery
Xpath to the node being replaced.
- mixed $node
String or Array (Usually a String) If string: Vaild XML. E.g. "<A/>" or "<A> foo <B/> bar <A/>" If array: A Node (can be a whole sub-tree) (See comment in header)
- bool $autoReindex
(optional, default=TRUE) Reindex the document to reflect the changes. A performance helper. See reindexNodeTree()
Return Value:
arrayThe last replaced $node (can be a whole sub-tree)
Similar Functions:
reindexNodeTree()
Line:
Defined on line 4639
Method Details: insertChild
function insertChild($xPathQuery, $node, $shiftRight=TRUE, $afterText=TRUE, $autoReindex=TRUE)
Insert passed node (or passed node-tree) at the node(s) that matches the xQuery.
With parameters you can define if the 'hit'-node is shifted to the right or left and if it's placed before of after the text-part. Per derfault the 'hit'-node is shifted to the right and the node takes the place the of the 'hit'-node. NOTE: When passing a xpath-query instead of an abs. Xpath. Depending on setModMatch() one, none or multiple nodes are affected. E.g. Following is given: AAA[1] / \ ..BBB[1]..BBB[2] .. a) insertChild('/AAA[1]/BBB[2]', <node CCC>) b) insertChild('/AAA[1]/BBB[2]', <node CCC>, $shiftRight=FALSE) c) insertChild('/AAA[1]/BBB[2]', <node CCC>, $shiftRight=FALSE, $afterText=FALSE) a) b) c) AAA[1] AAA[1] AAA[1] / | \ / | \ / | \ ..BBB[1]..CCC[1]BBB[2].. ..BBB[1]..BBB[2]..CCC[1] ..BBB[1]..BBB[2]CCC[1].. #### Do a complete review of the "(optional)" tag after several arguments.Parameter:
- string $xPathQuery
Xpath to the node to append.
- mixed $node
String or Array (Usually a String) If string: Vaild XML. E.g. "<A/>" or "<A> foo <B/> bar <A/>" If array: A Node (can be a whole sub-tree) (See comment in header)
- bool $shiftRight
(optional, default=TRUE) Shift the target node to the right.
- bool $afterText
(optional, default=TRUE) Insert after the text.
- bool $autoReindex
(optional, default=TRUE) Reindex the document to reflect the changes. A performance helper. See reindexNodeTree()
Return Value:
mixedFALSE on error (or no match). On success we return the path(s) to the newly appended nodes. That is: Array of paths if more then 1 node was added or a single path string if only one node was added. NOTE: If autoReindex is FALSE, then we can't return the *complete* path as the exact doc-pos isn't available without reindexing. In that case we leave out the last [docpos] in the path(s). ie we'd return /A[3]/B instead of /A[3]/B[2]
Similar Functions:
appendChildByXml(), reindexNodeTree()
Line:
Defined on line 4715
Method Details: appendChild
function appendChild($xPathQuery, $node, $afterText=FALSE, $autoReindex=TRUE)
Appends a child to anothers children.
If you intend to do a lot of appending, you should leave autoIndex as FALSE and then call reindexNodeTree() when you are finished all the appending.Parameter:
- string $xPathQuery
Xpath to the node to append to.
- mixed $node
String or Array (Usually a String) If string: Vaild XML. E.g. "<A/>" or "<A> foo <B/> bar <A/>" If array: A Node (can be a whole sub-tree) (See comment in header)
- bool $afterText
(optional, default=FALSE) Insert after the text.
- bool $autoReindex
(optional, default=TRUE) Reindex the document to reflect the changes. A performance helper. See reindexNodeTree()
Return Value:
mixedFALSE on error (or no match). On success we return the path(s) to the newly appended nodes. That is: Array of paths if more then 1 node was added or a single path string if only one node was added. NOTE: If autoReindex is FALSE, then we can't return the *complete* path as the exact doc-pos isn't available without reindexing. In that case we leave out the last [docpos] in the path(s). ie we'd return /A[3]/B instead of /A[3]/B[2]
Similar Functions:
insertChild(), reindexNodeTree()
Line:
Defined on line 4805
Method Details: insertBefore
function insertBefore($xPathQuery, $node, $afterText=TRUE, $autoReindex=TRUE)
Inserts a node before the reference node with the same parent.
If you intend to do a lot of appending, you should leave autoIndex as FALSE and then call reindexNodeTree() when you are finished all the appending.Parameter:
- string $xPathQuery
Xpath to the node to insert new node before
- mixed $node
String or Array (Usually a String) If string: Vaild XML. E.g. "<A/>" or "<A> foo <B/> bar <A/>" If array: A Node (can be a whole sub-tree) (See comment in header)
- bool $afterText
(optional, default=FLASE) Insert after the text.
- bool $autoReindex
(optional, default=TRUE) Reindex the document to reflect the changes. A performance helper. See reindexNodeTree()
Return Value:
mixedFALSE on error (or no match). On success we return the path(s) to the newly appended nodes. That is: Array of paths if more then 1 node was added or a single path string if only one node was added. NOTE: If autoReindex is FALSE, then we can't return the *complete* path as the exact doc-pos isn't available without reindexing. In that case we leave out the last [docpos] in the path(s). ie we'd return /A[3]/B instead of /A[3]/B[2]
Similar Functions:
reindexNodeTree()
Line:
Defined on line 4878
Method Details: getAttributes
function getAttributes($absoluteXPath, $attrName=NULL)
Retrieves a dedecated attribute value or a hash-array of all attributes of a node.
The first param $absoluteXPath must be a valid xpath OR a xpath-query that results to *one* xpath. If the second param $attrName is not set, a hash-array of all attributes of that node is returned. Optionally you may pass an attrubute name in $attrName and the function will return the string value of that attribute.Parameter:
- string $absoluteXPath
Full xpath OR a xpath-query that results to *one* xpath.
- string $attrName
(Optional) The name of the attribute. See above.
Return Value:
mixedhash-array or a string of attributes depending if the parameter $attrName was set (see above). FALSE if the node or attribute couldn't be found.
Similar Functions:
setAttribute(), removeAttribute()
Line:
Defined on line 4904
Method Details: setAttribute
function setAttribute($xPathQuery, $name, $value, $overwrite=TRUE)
Set attributes of a node(s).
This method sets a number single attributes. An existing attribute is overwritten (default) with the new value, but setting the last param to FALSE will prevent overwritten. NOTE: When passing a xpath-query instead of an abs. Xpath. Depending on setModMatch() one, none or multiple nodes are affected.Parameter:
- string $xPathQuery
xpath to the node (See note above).
- string $name
Attribute name.
- string $value
Attribute value.
- bool $overwrite
If the attribute is already set we overwrite it (see text above)
Return Value:
boolTRUE on success, FALSE on failure.
Similar Functions:
getAttribute(), removeAttribute()
Line:
Defined on line 4937
Method Details: setAttributes
function setAttributes($xPathQuery, $attributes, $overwrite=TRUE)
Version of setAttribute() that sets multiple attributes to node(s).
This method sets a number of attributes. Existing attributes are overwritten (default) with the new values, but setting the last param to FALSE will prevent overwritten. NOTE: When passing a xpath-query instead of an abs. Xpath. Depending on setModMatch() one, none or multiple nodes are affected.Parameter:
- string $xPathQuery
xpath to the node (See note above).
- array $attributes
associative array of attributes to set.
- bool $overwrite
If the attributes are already set we overwrite them (see text above)
Return Value:
boolTRUE on success, FALSE otherwise
Similar Functions:
setAttribute(), getAttribute(), removeAttribute()
Line:
Defined on line 4955
Method Details: removeAttribute
function removeAttribute($xPathQuery, $attrList=NULL)
Removes an attribute of a node(s).
This method removes *ALL* attributres per default unless the second parameter $attrList is set. $attrList can be either a single attr-name as string OR a vector of attr-names as array. E.g. removeAttribute(<xPath>); # will remove *ALL* attributes. removeAttribute(<xPath>, 'A'); # will only remove attributes called 'A'. removeAttribute(<xPath>, array('A_1','A_2')); # will remove attribute 'A_1' and 'A_2'. NOTE: When passing a xpath-query instead of an abs. Xpath. Depending on setModMatch() one, none or multiple nodes are affected.Parameter:
- string $xPathQuery
xpath to the node (See note above).
- mixed $attrList
(optional) if not set will delete *all* (see text above)
Return Value:
boolTRUE on success, FALSE if the node couldn't be found
Similar Functions:
getAttribute(), setAttribute()
Line:
Defined on line 4995
Method Details: getData
function getData($xPathQuery)
Retrieve all the text from a node as a single string.
Sample Given is: <AA> This <BB\>is <BB\> some<BB\>text </AA> Return of getData('/AA[1]') would be: " This is sometext " The first param $xPathQuery must be a valid xpath OR a xpath-query that results to *one* xpath.Parameter:
- string $xPathQuery
xpath to the node - resolves to *one* xpath.
Return Value:
mixedThe returned string (see above), FALSE if the node couldn't be found or is not unique.
Similar Functions:
getDataParts()
Line:
Defined on line 5034
Method Details: getDataParts
function getDataParts($xPathQuery)
Retrieve all the text from a node as a vector of strings
Where each element of the array was interrupted by a non-text child element. Sample Given is: <AA> This <BB\>is <BB\> some<BB\>text </AA> Return of getDataParts('/AA[1]') would be: array([0]=>' This ', [1]=>'is ', [2]=>' some', [3]=>'text '); The first param $absoluteXPath must be a valid xpath OR a xpath-query that results to *one* xpath.Parameter:
- string $xPathQuery
xpath to the node - resolves to *one* xpath.
Return Value:
mixedThe returned array (see above), or FALSE if node is not found or is not unique.
Similar Functions:
getData()
Line:
Defined on line 5056
Method Details: substringData
function substringData($absoluteXPath, $offset = 0, $count = NULL)
Retrieves a sub string of a text-part OR attribute-value.
This method retrieves the sub string of a specific text-part OR (if the $absoluteXPath references an attribute) the the sub string of the attribute value. If no 'direct referencing' is used (Xpath ends with text()[<part-number>]), then the first text-part of the node ist returned (if exsiting).Parameter:
- string $absoluteXPath
Xpath to the node (See note above).
- int $offset
(optional, default is 0) Starting offset. (Just like PHP's substr())
- number $count
(optional, default is ALL) Character count (Just like PHP's substr())
Return Value:
mixedThe sub string, FALSE if not found or on error
Similar Functions:
XPathEngine::wholeText(), PHP's substr()
Line:
Defined on line 5097
Method Details: replaceData
function replaceData($xPathQuery, $replacement, $offset = 0, $count = 0, $textPartNr=1)
Replace a sub string of a text-part OR attribute-value.
NOTE: When passing a xpath-query instead of an abs. Xpath. Depending on setModMatch() one, none or multiple nodes are affected.Parameter:
- string $xPathQuery
xpath to the node (See note above).
- string $replacement
The string to replace with.
- int $offset
(optional, default is 0) Starting offset. (Just like PHP's substr_replace ())
- number $count
(optional, default is 0=ALL) Character count (Just like PHP's substr_replace())
- int $textPartNr
(optional) (see _getTextSet() )
Return Value:
boolThe new string value on success, FALSE if not found or on error
Similar Functions:
substringData()
Line:
Defined on line 5120
Method Details: insertData
function insertData($xPathQuery, $data, $offset=0)
Insert a sub string in a text-part OR attribute-value.
NOTE: When passing a xpath-query instead of an abs. Xpath. Depending on setModMatch() one, none or multiple nodes are affected.Parameter:
- string $xPathQuery
xpath to the node (See note above).
- string $data
The string to replace with.
- int $offset
(optional, default is 0) Offset at which to insert the data.
Return Value:
boolThe new string on success, FALSE if not found or on error
Similar Functions:
replaceData()
Line:
Defined on line 5145
Method Details: appendData
function appendData($xPathQuery, $data, $textPartNr=1)
Append text data to the end of the text for an attribute OR node text-part.
This method adds content to a node. If it's an attribute node, then the value of the attribute will be set, otherwise the passed data will append to character data of the node text-part. Per default the first text-part is taken. NOTE: When passing a xpath-query instead of an abs. Xpath. Depending on setModMatch() one, none or multiple nodes are affected.Parameter:
- string $xPathQuery
to the node(s) (See note above).
- string $data
String containing the content to be added.
- int $textPartNr
(optional, default is 1) (see _getTextSet())
Return Value:
boolTRUE on success, otherwise FALSE
Similar Functions:
_getTextSet()
Line:
Defined on line 5165
Method Details: deleteData
function deleteData($xPathQuery, $offset=0, $count=0, $textPartNr=1)
Delete the data of a node.
This method deletes content of a node. If it's an attribute node, then the value of the attribute will be removed, otherwise the node text-part. will be deleted. Per default the first text-part is deleted. NOTE: When passing a xpath-query instead of an abs. Xpath. Depending on setModMatch() one, none or multiple nodes are affected.Parameter:
- string $xPathQuery
to the node(s) (See note above).
- int $offset
(optional, default is 0) Starting offset. (Just like PHP's substr_replace())
- number $count
(optional, default is 0=ALL) Character count. (Just like PHP's substr_replace())
- int $textPartNr
(optional, default is 0) the text part to delete (see _getTextSet())
Return Value:
boolTRUE on success, otherwise FALSE
Similar Functions:
_getTextSet()
Line:
Defined on line 5191
Method Details: decodeEntities
function decodeEntities($encodedData, $reverse=FALSE)
Decodes the character set entities in the given string.
This function is given for convenience, as all text strings or attributes are going to come back to you with their entities still encoded. You can use this function to remove these entites. It makes use of the get_html_translation_table(HTML_ENTITIES) php library call, so is limited in the same ways. At the time of writing this seemed be restricted to iso-8859-1 ### Provide an option that will do this by default.Parameter:
- mixed $encodedData
The string or array that has entities you would like to remove
- bool $reverse
If TRUE entities will be encoded rather than decoded, ie < to < rather than < to <.
Return Value:
mixedThe string or array returned with entities decoded.
Line:
Defined on line 5225
Method Details: _xml2Document
function &_xml2Document($xmlString)
Parse the XML to a node-tree. A so called 'document'
Parameter:
- string $xmlString
The string to turn into a document node.
Return Value:
&arraya node-tree
Line:
Defined on line 5262
Method Details: _getTextSet
function _getTextSet($xPathQuery, $textPartNr=1)
Get a reference-list to node text part(s) or node attribute(s).
If the Xquery references an attribute(s) (Xquery ends with attribute::), then the text value of the node-attribute(s) is/are returned. Otherwise the Xquery is referencing to text part(s) of node(s). This can be either a direct reference to text part(s) (Xquery ends with text()[<nr>]) or indirect reference (a simple Xquery to node(s)). 1) Direct Reference (Xquery ends with text()[<part-number>]): If the 'part-number' is omitted, the first text-part is assumed; starting by 1. Negative numbers are allowed, where -1 is the last text-part a.s.o. 2) Indirect Reference (a simple Xquery to node(s)): Default is to return the first text part(s). Optionally you may pass a parameter $textPartNr to define the text-part you want; starting by 1. Negative numbers are allowed, where -1 is the last text-part a.s.o. NOTE I : The returned vector is a set of references to the text parts / attributes. This is handy, if you wish to modify the contents. NOTE II: text-part numbers out of range will not be in the list NOTE III:Instead of an absolute xpath you may also pass a xpath-query. Depending on setModMatch() one, none or multiple nodes are affected.Parameter:
- string $xPathQuery
xpath to the node (See note above).
- int $textPartNr
String containing the content to be set.
Return Value:
mixedA vector of *references* to the text that match, or FALSE on error
Similar Functions:
XPathEngine::wholeText()
Line:
Defined on line 5305
Method Details: _resolveXPathQueryForNodeMod
function _resolveXPathQueryForNodeMod($xPathQuery, $functionName)
Resolves an xPathQuery vector for a node op for modification
It is possible to create a brand new object, and try to append and insert nodes into it, so this is a version of _resolveXPathQuery() that will autocreate the super root if it detects that it is not present and the $xPathQuery is empty. Also it demands that there be at least one node returned, and displays a suitable error message if the returned xPathSet does not contain any nodes.Parameter:
- string $xPathQuery
An xpath query targeting a single node. If empty() returns the root node and auto creates the root node if it doesn't exist.
- string $function
The function in which this check was called
Return Value:
arrayVector of $absoluteXPath's (May be empty)
Similar Functions:
_resolveXPathQuery()
Line:
Defined on line 5417
Method Details: _resolveXPathQuery
function _resolveXPathQuery($xPathQuery, $function)
Resolves an xPathQuery vector depending on the property['modMatch']
To: - all matches, - the first - none (If the query matches more then one node.) see setModMatch() for detailsParameter:
- string $xPathQuery
An xpath query targeting a single node. If empty() returns the root node (if it exists).
- string $function
The function in which this check was called
Return Value:
arrayVector of $absoluteXPath's (May be empty)
Similar Functions:
setModMatch()
Line:
Defined on line 5454
Method Details: _title
function _title($title)
Produces a short title line.
Line:
Defined on line 5505
To update the documentation, run the GeneratePhpDocumentation.pl script on your copy of XPath.class.php and pipe the output to Php.XPathDocumentation.xml. Reloading this page will then show uptodate documentation for your version of Php.XPath.