| packageless

# Class: XPath Source Location: /lib/XPath/XPath.class.php
### Class Overview
    XPathBase
       |
       --XPathEngine
          |
          --XPath
********************************************************************************************** | ### Methods XPath appendChild appendData deleteData getAttributes getData getDataParts insertBefore insertChild insertData nodeName removeAttribute removeChild replaceChild replaceChildByData replaceData reset setAttribute setAttributes setModMatch substringData _getTextSet _resolveXPathQuery _resolveXPathQueryForNodeMod _xml2Document
### Inherited Variables #### Class: XPathEngine XPathEngine::$axes XPathEngine::$axPathLiterals XPathEngine::$emptyNode XPathEngine::$errorStrings XPathEngine::$functions XPathEngine::$nodeIndex XPathEngine::$nodeRoot XPathEngine::$nodeStack XPathEngine::$operators XPathEngine::$parsedTextLocation XPathEngine::$parseOptions XPathEngine::$parseSkipWhiteCache XPathEngine::$parseStackIndex XPathEngine::$parsInCData XPathEngine::$_indexIsDirty #### Class: XPathBase XPathBase::$aDebugOpenLinks XPathBase::$bDebugXmlParse XPathBase::$iDebugNextLinkNumber XPathBase::$_lastError | ### Inherited Methods #### Class: XPathEngine XPathEngine::XPathEngine() Constructor XPathEngine::cloneNode() Clone a node and it's child nodes. XPathEngine::decodeEntities() Decodes the character set entities in the given string. XPathEngine::equalNodes() Compare two nodes to see if they are equal (point to the same node in the doc) XPathEngine::evaluate() Alias for the match function XPathEngine::exportAsHtml() Returns the containing XML as marked up HTML with specified nodes hi-lighted XPathEngine::exportAsXml() Given a context this function returns the containing XML XPathEngine::exportToFile() Generates a XML string with the content of the current document and writes it to a file. XPathEngine::getNode() Get the node defined by the $absoluteXPath. XPathEngine::getNodePath() Get the absolute XPath of a node that is in a document tree. XPathEngine::getParentXPath() Retrieves the absolute parent XPath query. XPathEngine::getProperties() Returns the property/ies you want. XPathEngine::hasChildNodes() Returns TRUE if the given node has child nodes below it XPathEngine::importFromFile() Reads a file or URL and parses the XML data. XPathEngine::importFromString() Reads a string and parses the XML data. XPathEngine::match() Matches (evaluates) an XPath query XPathEngine::reindexNodeTree() Update nodeIndex and every node of the node-tree. XPathEngine::reset() Resets the object so it's able to take a new xml sting/file XPathEngine::setCaseFolding() Alternative way to control whether case-folding is enabled for this XML parser. XPathEngine::setSkipWhiteSpaces() Alternative way to control whether skip-white-spaces is enabled for this XML parser. XPathEngine::setXmlOption() Set an xml_parser_set_option() XPathEngine::setXmlOptions() Sets a number of xml_parser_set_option()s XPathEngine::wholeText() Get a the content of a node text part or node attribute. XPathEngine::_addLiteral() Adds a literal to our array of literals XPathEngine::_asLiteral() Returns the given string as a literal reference. XPathEngine::_checkNodeTest() Checks whether a node matches a node-test. XPathEngine::_checkPredicates() Checks whether a node matches predicates. XPathEngine::_createSuperRoot() Creates a super root node. XPathEngine::_evaluateExpr() Internal recursive evaluate an-XPath-expression function. XPathEngine::_evaluateFunction() Evaluates an XPath function XPathEngine::_evaluatePathExpr() Internal recursive evaluate an Path expression. XPathEngine::_evaluateStep() Evaluate a step from a XPathQuery expression at a specific contextPath. XPathEngine::_export() Generates a XML string with the content of the current document. XPathEngine::_getAxis() Retrieves axis information from an XPath query step. XPathEngine::_handleAxis_ancestor() Handles the XPath ancestor axis. XPathEngine::_handleAxis_ancestor_or_self() Handles the XPath ancestor-or-self axis. XPathEngine::_handleAxis_attribute() Handles the XPath attribute axis. XPathEngine::_handleAxis_child() Handles the XPath child axis. XPathEngine::_handleAxis_descendant() Handles the XPath descendant axis. XPathEngine::_handleAxis_descendant_or_self() Handles the XPath descendant-or-self axis. XPathEngine::_handleAxis_following() Handles the XPath following axis. XPathEngine::_handleAxis_following_sibling() Handles the XPath following-sibling axis. XPathEngine::_handleAxis_namespace() Handles the XPath namespace axis. XPathEngine::_handleAxis_parent() Handles the XPath parent axis. XPathEngine::_handleAxis_preceding() Handles the XPath preceding axis. XPathEngine::_handleAxis_preceding_sibling() Handles the XPath preceding-sibling axis. XPathEngine::_handleAxis_self() Handles the XPath self axis. XPathEngine::_handleCharacterData() Handles character data while parsing. XPathEngine::_handleDefaultData() Default handler for the XML parser. XPathEngine::_handleEndElement() Handles closing XML tags while parsing. XPathEngine::_handleFunction_boolean() Handles the XPath function boolean. XPathEngine::_handleFunction_ceiling() Handles the XPath function ceiling. XPathEngine::_handleFunction_concat() Handles the XPath function concat. XPathEngine::_handleFunction_contains() Handles the XPath function contains. XPathEngine::_handleFunction_count() Handles the XPath function count. XPathEngine::_handleFunction_false() Handles the XPath function FALSE. XPathEngine::_handleFunction_floor() Handles the XPath function floor. XPathEngine::_handleFunction_id() Handles the XPath function id. XPathEngine::_handleFunction_lang() Handles the XPath function lang. XPathEngine::_handleFunction_last() Handles the XPath function last. XPathEngine::_handleFunction_name() Handles the XPath function name. XPathEngine::_handleFunction_normalize_space() Handles the XPath function normalize-space. XPathEngine::_handleFunction_not() Handles the XPath function not. XPathEngine::_handleFunction_number() Handles the XPath function number. XPathEngine::_handleFunction_position() Handles the XPath function position. XPathEngine::_handleFunction_round() Handles the XPath function round. XPathEngine::_handleFunction_starts_with() Handles the XPath function starts-with. XPathEngine::_handleFunction_string() Handles the XPath function string. XPathEngine::_handleFunction_string_length() Handles the XPath function string-length. XPathEngine::_handleFunction_substring() Handles the XPath function substring. XPathEngine::_handleFunction_substring_after() Handles the XPath function substring-after. XPathEngine::_handleFunction_substring_before() Handles the XPath function substring-before. XPathEngine::_handleFunction_sum() Handles the XPath function sum. XPathEngine::_handleFunction_translate() Handles the XPath function translate. XPathEngine::_handleFunction_true() Handles the XPath function TRUE. XPathEngine::_handleFunction_x_lower() Handles the XPath function x-lower. XPathEngine::_handleFunction_x_upper() Handles the XPath function x-upper. XPathEngine::_handlePI() Handles processing instruction (PI) XPathEngine::_handleStartElement() Handles opening XML tags while parsing. XPathEngine::_internalAppendChild() Adds a new node to the XML document tree during xml parsing. XPathEngine::_InternalExport() Export the xml document starting at the named node. XPathEngine::_recursiveReindexNodeTree() Here's where the work is done for reindexing (see reindexNodeTree) XPathEngine::_removeLiterals() Parse out the literals of an XPath expression. XPathEngine::_sortByDocOrder() Sort an xPathSet by doc order. XPathEngine::_translateAmpersand() Translate all ampersands to it's literal entities '&amp;' and back. #### Class: XPathBase XPathBase::XPathBase() Constructor XPathBase::getLastError() Returns the last occured error message. XPathBase::reset() Resets the object so it's able to take a new xml sting/file XPathBase::setVerbose() Alter the verbose (error) level reporting. XPathBase::_afterstr() Retrieves a substring after a delimiter. XPathBase::_beginDebugFunction() Called to begin the debug run of a function. XPathBase::_bracketExplode() Split a string by a searator-string -- BUT the separator-string must be located *outside* of any brackets. XPathBase::_bracketsCheck() This method checks the right amount and match of brackets XPathBase::_closeDebugFunction() Called to end the debug run of a function. XPathBase::_displayError() Displays an error message. XPathBase::_displayMessage() Displays a diagnostic message XPathBase::_getEndGroups() Split a string at it's groups, ie bracketed expressions XPathBase::_prestr() Retrieves a substring before a delimiter. XPathBase::_printContext() Echo an XPath context for diagnostic purposes XPathBase::_profileFunction() Call to return time since start of function for Profiling XPathBase::_searchString() Looks for a string within another string -- BUT the search-string must be located *outside* of any brackets. XPathBase::_setLastError() Creates a textual error message and sets it. XPathBase::_treeDump() This is a debug helper function. It dumps the node-tree as HTML
### Class Details [line 4515] ********************************************************************************************** =============================================================================================== X P a t h E n g i n e - Class =============================================================================================== ********************************************************************************************** [ Top ] ### Class Methods ### constructor XPath [line 4531]
`XPath XPath( [$userXmlOptions $fileName = ''], [$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); #### Tags:
see: | XPathEngine::XPathEngine()
#### Parameters:
$userXmlOptions | $fileName | (array) (optional) Vector of (<optionID>=><value>, <optionID>=><value>, ...)
$fileName | $userXmlOptions | (string) (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.
[ Top ] ### method appendChild [line 4943]
`(mixed) appendChild( $xPathQuery $xPathQuery, $node $node, [$afterText $afterText = FALSE], [$autoReindex $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. #### Tags:
return: | FALSE 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]
see: | XPath::insertChild(), XPathEngine::reindexNodeTree()
#### Parameters:
$xPathQuery | $xPathQuery | (string) Xpath to the node to append to.
$node | $node | (mixed) 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)
$afterText | $afterText | (bool) (optional, default=FALSE) Insert after the text.
$autoReindex | $autoReindex | (bool) (optional, default=TRUE) Reindex the document to reflect the changes. A performance helper. See reindexNodeTree()
[ Top ] ### method appendData [line 5309]
`(bool) appendData( $xPathQuery $xPathQuery, $data $data, [$textPartNr $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. #### Tags:
return: | TRUE on success, otherwise FALSE
see: | XPath::_getTextSet()
#### Parameters:
$xPathQuery | $xPathQuery | (string) to the node(s) (See note above).
$data | $data | (string) String containing the content to be added.
$textPartNr | $textPartNr | (int) (optional, default is 1) (see _getTextSet())
[ Top ] ### method deleteData [line 5335]
`(bool) deleteData( $xPathQuery $xPathQuery, [$offset $offset = 0], [$count $count = 0], [$textPartNr $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. #### Tags:
return: | TRUE on success, otherwise FALSE
see: | XPath::_getTextSet()
#### Parameters:
$xPathQuery | $xPathQuery | (string) to the node(s) (See note above).
$offset | $offset | (int) (optional, default is 0) Starting offset. (Just like PHP's substr_replace())
$count | $count | (number) (optional, default is 0=ALL) Character count. (Just like PHP's substr_replace())
$textPartNr | $textPartNr | (int) (optional, default is 0) the text part to delete (see _getTextSet())
[ Top ] ### method getAttributes [line 5049]
`(mixed) getAttributes( $absoluteXPath $absoluteXPath, [$attrName $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. #### Tags:
return: | hash-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.
see: | XPath::setAttribute(), XPath::removeAttribute()
#### Parameters:
$absoluteXPath | $absoluteXPath | (string) Full xpath OR a xpath-query that results to *one* xpath.
$attrName | $attrName | (string) (Optional) The name of the attribute. See above.
[ Top ] ### method getData [line 5179]
`(mixed) getData( $xPathQuery $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. #### Tags:
return: | The returned string (see above), FALSE if the node couldn't be found or is not unique.
see: | XPath::getDataParts()
#### Parameters:
$xPathQuery | $xPathQuery | (string) xpath to the node - resolves to *one* xpath.
[ Top ] ### method getDataParts [line 5201]
`(mixed) getDataParts( $xPathQuery $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. #### Tags:
return: | The returned array (see above), or FALSE if node is not found or is not unique.
see: | XPath::getData()
#### Parameters:
$xPathQuery | $xPathQuery | (string) xpath to the node - resolves to *one* xpath.
[ Top ] ### method insertBefore [line 5023]
`(mixed) insertBefore( $xPathQuery $xPathQuery, $node $node, [$afterText $afterText = TRUE], [$autoReindex $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. #### Tags:
return: | FALSE 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]
see: | XPathEngine::reindexNodeTree()
#### Parameters:
$xPathQuery | $xPathQuery | (string) Xpath to the node to insert new node before
$node | $node | (mixed) 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)
$afterText | $afterText | (bool) (optional, default=FLASE) Insert after the text.
$autoReindex | $autoReindex | (bool) (optional, default=TRUE) Reindex the document to reflect the changes. A performance helper. See reindexNodeTree()
[ Top ] ### method insertChild [line 4845]
`(mixed) insertChild( $xPathQuery $xPathQuery, $node $node, [$shiftRight $shiftRight = TRUE], [$afterText $afterText = TRUE], [$autoReindex $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. #### Tags:
return: | FALSE 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]
see: | appendChildByXml(), XPathEngine::reindexNodeTree()
#### Parameters:
$xPathQuery | $xPathQuery | (string) Xpath to the node to append.
$node | $node | (mixed) 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)
$shiftRight | $shiftRight | (bool) (optional, default=TRUE) Shift the target node to the right.
$afterText | $afterText | (bool) (optional, default=TRUE) Insert after the text.
$autoReindex | $autoReindex | (bool) (optional, default=TRUE) Reindex the document to reflect the changes. A performance helper. See reindexNodeTree()
[ Top ] ### method insertData [line 5289]
`(bool) insertData( $xPathQuery $xPathQuery, $data $data, [$offset $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. #### Tags:
return: | The new string on success, FALSE if not found or on error
see: | XPath::replaceData()
#### Parameters:
$xPathQuery | $xPathQuery | (string) xpath to the node (See note above).
$data | $data | (string) The string to replace with.
$offset | $offset | (int) (optional, default is 0) Offset at which to insert the data.
[ Top ] ### method nodeName [line 4599]
`(mixed) nodeName( $xPathQuery $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. #### Tags:
return: | Array or single string of the names of the specified nodes, or just the individual name. If the node did not exist, then returns FALSE.
#### Parameters:
$xPathQuery | $xPathQuery | (mixed) Array or single full document path(s) of the node(s), from which the names should be retrieved.
[ Top ] ### method removeAttribute [line 5140]
`(bool) removeAttribute( $xPathQuery $xPathQuery, [$attrList $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. #### Tags:
return: | TRUE on success, FALSE if the node couldn't be found
see: | getAttribute(), XPath::setAttribute()
#### Parameters:
$xPathQuery | $xPathQuery | (string) xpath to the node (See note above).
$attrList | $attrList | (mixed) (optional) if not set will delete *all* (see text above)
[ Top ] ### method removeChild [line 4640]
`(bool) removeChild( $xPathQuery $xPathQuery, [$autoReindex $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. #### Tags:
return: | TRUE on success, FALSE on error;
see: | XPath::setModMatch(), XPathEngine::reindexNodeTree()
#### Parameters:
$xPathQuery | $xPathQuery | (string) xpath to the node (See note above).
$autoReindex | $autoReindex | (bool) (optional, default=TRUE) Reindex the document to reflect the changes. A performance helper. See reindexNodeTree()
[ Top ] ### method replaceChild [line 4760]
`(array) &replaceChild( $xPathQuery $xPathQuery, $node $node, [$autoReindex $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. #### Tags:
return: | The last replaced $node (can be a whole sub-tree)
see: | XPathEngine::reindexNodeTree()
#### Parameters:
$xPathQuery | $xPathQuery | (string) Xpath to the node being replaced.
$node | $node | (mixed) 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)
$autoReindex | $autoReindex | (bool) (optional, default=TRUE) Reindex the document to reflect the changes. A performance helper. See reindexNodeTree()
[ Top ] ### method replaceChildByData [line 4705]
`(bool) replaceChildByData( $xPathQuery $xPathQuery, $data $data, [$autoReindex $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. #### Tags:
return: | TRUE on success, FALSE on error;
see: | XPath::setModMatch(), XPath::replaceChild(), XPathEngine::reindexNodeTree()
#### Parameters:
$xPathQuery | $xPathQuery | (string) xpath to the node (See note above).
$data | $data | (string) String containing the content to be set. *READONLY*
$autoReindex | $autoReindex | (bool) (optional, default=TRUE) Reindex the document to reflect the changes. A performance helper. See reindexNodeTree()
[ Top ] ### method replaceData [line 5264]
`(bool) replaceData( $xPathQuery $xPathQuery, $replacement $replacement, [$offset $offset = 0], [$count $count = 0], [$textPartNr $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. #### Tags:
return: | The new string value on success, FALSE if not found or on error
see: | XPath::substringData()
#### Parameters:
$xPathQuery | $xPathQuery | (string) xpath to the node (See note above).
$replacement | $replacement | (string) The string to replace with.
$offset | $offset | (int) (optional, default is 0) Starting offset. (Just like PHP's substr_replace ())
$count | $count | (number) (optional, default is 0=ALL) Character count (Just like PHP's substr_replace())
$textPartNr | $textPartNr | (int) (optional) (see _getTextSet() )
[ Top ] ### method reset [line 4547]
`void 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. Overrides XPathEngine::reset() (Resets the object so it's able to take a new xml sting/file) [ Top ] ### method setAttribute [line 5082]
`(bool) setAttribute( $xPathQuery $xPathQuery, $name $name, $value $value, [$overwrite $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. #### Tags:
return: | TRUE on success, FALSE on failure.
see: | getAttribute(), XPath::removeAttribute()
#### Parameters:
$xPathQuery | $xPathQuery | (string) xpath to the node (See note above).
$name | $name | (string) Attribute name.
$value | $value | (string) Attribute value.
$overwrite | $overwrite | (bool) If the attribute is already set we overwrite it (see text above)
[ Top ] ### method setAttributes [line 5100]
`(bool) setAttributes( $xPathQuery $xPathQuery, $attributes $attributes, [$overwrite $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. #### Tags:
return: | TRUE on success, FALSE otherwise
see: | XPath::setAttribute(), getAttribute(), XPath::removeAttribute()
#### Parameters:
$xPathQuery | $xPathQuery | (string) xpath to the node (See note above).
$attributes | $attributes | (array) associative array of attributes to set.
$overwrite | $overwrite | (bool) If the attributes are already set we overwrite them (see text above)
[ Top ] ### method setModMatch [line 4570]
`void setModMatch( [$modMatch $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() #### Tags:
see: | XPath::_resolveXPathQuery()
#### Parameters:
$modMatch | $modMatch | (int) One of the following: XPATH_QUERYHIT_ALL (default) XPATH_QUERYHIT_FIRST XPATH_QUERYHIT_UNIQUE // If the query matches more then one node.
[ Top ] ### method substringData [line 5241]
`(mixed) substringData( $absoluteXPath $absoluteXPath, [$offset $offset = 0], [$count $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). #### Tags:
return: | The sub string, FALSE if not found or on error
see: | XPathEngine::wholeText(), PHP's substr()
#### Parameters:
$absoluteXPath | $absoluteXPath | (string) Xpath to the node (See note above).
$offset | $offset | (int) (optional, default is 0) Starting offset. (Just like PHP's substr())
$count | $count | (number) (optional, default is ALL) Character count (Just like PHP's substr())
[ Top ] ### method _getTextSet [line 5400]
`(mixed) _getTextSet( $xPathQuery $xPathQuery, [$textPartNr $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. #### Tags:
return: | A vector of *references* to the text that match, or FALSE on error
see: | XPathEngine::wholeText()
#### Parameters:
$xPathQuery | $xPathQuery | (string) xpath to the node (See note above).
$textPartNr | $textPartNr | (int) String containing the content to be set.
[ Top ] ### method _resolveXPathQuery [line 5549]
`(array) _resolveXPathQuery( $xPathQuery $xPathQuery, $function $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 details #### Tags:
return: | Vector of $absoluteXPath's (May be empty)
see: | XPath::setModMatch()
#### Parameters:
$xPathQuery | $xPathQuery | (string) An xpath query targeting a single node. If empty() returns the root node (if it exists).
$function | $function | (string) The function in which this check was called
[ Top ] ### method _resolveXPathQueryForNodeMod [line 5512]
`(array) _resolveXPathQueryForNodeMod( $xPathQuery $xPathQuery, $function $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. #### Tags:
return: | Vector of $absoluteXPath's (May be empty)
see: | XPath::_resolveXPathQuery()
#### Parameters:
$xPathQuery | $xPathQuery | (string) An xpath query targeting a single node. If empty() returns the root node and auto creates the root node if it doesn't exist.
$function | $functionName | (string) The function in which this check was called
[ Top ] ### method _xml2Document [line 5357]
`(&array) &_xml2Document( $xmlString $xmlString)`
Parse the XML to a node-tree. A so called 'document' #### Tags:
return: | a node-tree
#### Parameters:
$xmlString | $xmlString | (string) The string to turn into a document node.
[ Top ] Documentation generated on Mon, 29 Dec 2003 21:16:25 +0100 by phpDocumentor 1.2.3