XML_XPath
[ class tree: XML_XPath ] [ index: XML_XPath ] [ all elements ]

Class: XML_XPath_result

Source Location: /XML_XPath-1.2.4/XPath/result.php

Class Overview

XML_XPath_common
   |
   --XML_XPath_result

Interface for an XML_XPath result so that one can cycle through the result set and manipulate the main tree with DOM methods using a seperate pointer then the original class.


Author(s):

Version:

  • Revision: 1.1

Variables

Methods


Inherited Variables

Inherited Methods

Class: XML_XPath_common

XML_XPath_common::appendChild()
Adds the node or document fragment to the end of the list of children. If the node is already in the tree it is first removed (not sure if this works yet)
XML_XPath_common::appendData()
Will append data to end of text node.
XML_XPath_common::childNodes()
Retrieves the child nodes from the element node as an XML_XPath_result object
XML_XPath_common::cloneNode()
Clones the node and return the node as a result object
XML_XPath_common::deleteData()
Will delete data at offset and for count for a text node.
XML_XPath_common::documentElement()
Move to the document element
XML_XPath_common::dumpChildren()
Returns all the contents of an element node, regardless of type, as is.
XML_XPath_common::evaluate()
Evaluate the xpath expression on the loaded xml document.
XML_XPath_common::firstChild()
Moves the pointer to the first child of this node or returns the first node.
XML_XPath_common::getAttribute()
Retrieves an attribute value by name from the element node at the current pointer.
XML_XPath_common::getAttributes()
Return an associative array of attribute names as the keys and attribute values as the values. This is not a DOM function, but is a convenient addition.
XML_XPath_common::getElementsByTagName()
Create an XML_XPath_result object with the elements with the specified tagname
XML_XPath_common::getNodePath()
Resolve the xpath location of the current node
XML_XPath_common::getOne()
A quick version of the evaluate, where the results are returned immediately. This function is equivalent to xsl:value-of select in every way.
XML_XPath_common::getPointer()
Get the current pointer in the xml document.
XML_XPath_common::hasAttribute()
Returns true when an attribute with a given name is specified on this element false otherwise.
XML_XPath_common::hasAttributes()
Returns whether this node has any attributes.
XML_XPath_common::hasChildNodes()
Returns whether this node has any children.
XML_XPath_common::insertBefore()
Inserts the node before the current pointer.
XML_XPath_common::insertData()
Will insert data at offset for a text node.
XML_XPath_common::lastChild()
Moves the pointer to the last child of this node or returns the last child.
XML_XPath_common::nextSibling()
Moves the internal pointer to the next sibling of the current node, or returns the pointer.
XML_XPath_common::nodeName()
Return the name of this node, depending on its type, according to the DOM recommendation
XML_XPath_common::nodeType()
Returns the integer value constant corresponding to the DOM node type
XML_XPath_common::parentNode()
Moves the internal pointer to the parent of the current node or returns the pointer.
XML_XPath_common::previousSibling()
Moves the internal pointer to the previous sibling of the current node or returns the pointer.
XML_XPath_common::removeAttribute()
Remove the attribute by name.
XML_XPath_common::removeChild()
Removes the child node at the current pointer and returns it.
XML_XPath_common::replaceChild()
Replaces the old child with the new child. If the new child is already in the document, it is first removed (not implemented yet). If the new child is a document fragment, then all of the nodes are inserted in the location of the old child.
XML_XPath_common::replaceChildren()
Not in the DOM specification, but certainly a convenient function. Allows you to pass in an xml document fragment which will be parsed into an xml object and merged into the xml document, replacing all the previous children of the node. It does this by shallow cloning the node, restoring the attributes and then adding the parsed children.
XML_XPath_common::replaceData()
Will replace data at offset and for count with content
XML_XPath_common::setAttribute()
Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of the value parameter.
XML_XPath_common::setPointer()
Set the pointer in the xml document
XML_XPath_common::substringData()
Extracts a range of data from the node. Takes an offset and a count, which are optional and will default to retrieving the whole string. If an XML_ELEMENT_NODE provided, then it first concats all the adjacent text nodes recusively and works on those.
XML_XPath_common::toFile()
Exports the xml document to a file. Only works for the whole document right now.
XML_XPath_common::toString()
Export the xml document to a string, beginning from the pointer.

Class Details

[line 53]
Interface for an XML_XPath result so that one can cycle through the result set and manipulate the main tree with DOM methods using a seperate pointer then the original class.
  • Author: Dan Allen <dan@mojavelinux.com>
  • Version: Revision: 1.1
  • Since: PHP 4.2.1
  • Access: public


[ Top ]


Class Variables

$ctx =

[line 84]

xpath context object for the current domxml object

Type:   object


[ Top ]

$data =

[line 78]

either array of nodesets, string, boolean or number from xpath/DOM query

Type:   mixed


[ Top ]

$isRewound =

[line 66]

determines if we have counted the first node of the result nodeset

Type:   boolean


[ Top ]

$query =

[line 60]

original xpath query, stored when we need to sort

Type:   string


[ Top ]

$type =

[line 72]

The type of result that the query generated

Type:   int


[ Top ]

$xml =

[line 90]

domxml object, need for many common functions

Type:   object


[ Top ]



Method Detail

XML_XPath_result (Constructor)   [line 94]

XML_XPath_result XML_XPath_result( $in_data, $in_type, $in_query, &$in_ctx, &$in_xml)


Parameters:

   $in_data   — 
   $in_type   — 
   $in_query   — 
   &$in_ctx   — 
   &$in_xml   — 

[ Top ]

current   [line 469]

object XML_XPath current( )

Retrieve current pointer

If the result is a nodeset (which is the most common use of the result object) than this function returns the current pointer in the result array.

  • Return: pointer
  • Access: public

[ Top ]

end   [line 487]

boolean end( )

Move to last result node, if this is an XPATH_NODESET
  • Return: success
  • Access: public

[ Top ]

free   [line 506]

void free( )

Free the result object in order to save memory.
  • Access: public

[ Top ]

getData   [line 116]

mixed getData( )

Return the data from the xpath query. This function will be used mostly for xpath queries that result in scalar results, but in the case of nodesets, returns size
  • Return: scalar result from xpath query or size of nodeset
  • Access: public

[ Top ]

getIndex   [line 176]

int getIndex( )

Return the index of the result nodeset.
  • Return: current index of the result nodeset
  • Access: public

[ Top ]

next   [line 367]

boolean next( )

Move to the next node in the nodeset of results. This can be used inside of a while loop, so that it is possible to step through the nodes one by one.

It is important to note that the first call to next will put the pointer at the first index and not the second...this is just a more convenient way of handling the logic. If you rewind() the data and then call next() as the conditional on a while loop, you can work through each of the results from the first to the last.

  • Return: success node found and pointer advanced
  • Access: public

[ Top ]

nextByNodeName   [line 400]

boolean nextByNodeName( string $in_name)

Move to the next node in the nodeset of results where the node has the name provided.

This can be used inside of a while loop, so that it is possible to step through the nodes one by one.

  • Return: next node existed and pointer moved
  • Access: public

Parameters:

string   $in_name   —  name of node to find

[ Top ]

nextByNodeType   [line 435]

boolean nextByNodeType( int $in_type)

Move to the next node in the nodeset of results where the node has the type provided.

This can be used inside of a while loop, so that it is possible to step through the nodes one by one.

  • Return: next node existed and pointer moved
  • Access: public

Parameters:

int   $in_type   —  type of node to find

[ Top ]

numResults   [line 163]

int numResults( )

Return the number of nodes if the result is a nodeset or 1 for scalar results.

result (boolean, string, numeric) xpath queries

  • Return: number of results returned by xpath query
  • Access: public

[ Top ]

resultType   [line 148]

int resultType( )

Retrieve the type of result that was returned by the xpath query.
  • Return: code corresponding to the xpath result types constants
  • Access: public

[ Top ]

rewind   [line 342]

boolean rewind( )

Reset the result index back to the beginning, if this is an XPATH_NODESET
  • Return: success
  • Access: public

[ Top ]

sort   [line 202]

boolean sort( [string $in_sortXpath = '.'], [int $in_order = XML_XPATH_SORT_TEXT_ASCENDING], [ $in_permanent = false])

Sort the nodeset in this result. The sort can be either ascending or descending, and the comparisons can be text, number or natural (see the constants above). The sort axis is provided as an xpath query and is the location path relative to the node given.

For example, so sort on an attribute, you would provide '@foo' and it will look at the attribute for each node.

NOTE: If the axis is not found, the node will comes first in the sort order for ascending order and at the end for descending orde.

  • Return: success (return false if nothing to sort)
  • Access: public

Parameters:

string   $in_sortXpath   —  relative xpath query location to each node in nodeset
int   $in_order   —  either XML_XPATH_SORT_TEXT_[DE|A]SCENDING, XML_XPATH_SORT_NUMBER_[DE|A]SCENDING, XML_XPATH_SORT_NATURAL_[DE|A]SCENDING
   $in_permanent   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:44:42 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.