Constructor of the class.
This constructor initializes the class and, when a filename is given, tries to read and parse the given file.
XML
XML
([string $file = ""], [mixed $debug = ""])
-
string
$file: Path and name of the file to read and parsed.
Add attributes to a node.
This method adds attributes to a node. Existing attributes will not be overwritten.
void
add_attributes
(string $path, array $attributes)
-
string
$path: Full document path of the node, the attributes should be added to.
-
array
$attributes: Associative array containing the new attributes for the node.
Add content to a node.
This method adds content to a node. If it's an attribute node, then the value of the attribute will be set, otherwise the character data of the node will be set. The content is appended to existing content, so nothing will be overwritten.
void
add_content
(string $path, string $value)
-
string
$path: Full document path of the node.
-
string
$value: String containing the content to be added.
Adds a new node to the XML document.
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.
string
add_node
(mixed $context, string $name, string $content)
-
string
$content: Full path of the parent, to which the new node should be added as a child.
-
string
$name: Name of the new node.
Retrieves a substring after a delimiter.
This method retrieves everything from a string after a given delimiter, not including the delimiter.
string
afterstr
(string $string, string $delimiter)
-
string
$string: String, from which the substring should be extracted.
-
string
$delimiter: String containing the delimiter to use.
Checks whether a node matches a node-test.
This method checks whether a node in the document matches a given node-test.
boolean
check_node_test
(string $context, string $node_test)
-
string
$context: Full path of the node, which should be tested for matching the node-test.
-
string
$node_test: String containing the node-test for the node.
Checks whether a node matches predicates.
This method checks whether a list of nodes passed to this method match a given list of predicates.
array
check_predicates
(array $nodes, array $predicates)
-
array
$nodes: Array of full paths of all nodes to be tested.
-
array
$predicates: Array of predicates to use.
Displays an error message.
This method displays an error messages and stops the execution of the script. This method is called exactly in the same way as the printf function. The first argument contains the message and additional arguments of various types may be passed to this method to be inserted into the message.
void
display_error
(string $message)
-
string
$message: Error message to be displayed.
Evaluates an XPath expression.
This method tries to evaluate an XPath expression by parsing it. A XML document has to be read before this method is able to work.
array
evaluate
(string $path, [string $context = ""])
-
string
$path: XPath expression to be evaluated.
-
string
$context: Full path of a document node, starting from which the XPath expression should be evaluated.
Evaluates an XPath function
This method evaluates a given XPath function with its arguments on a specific node of the document.
mixed
evaluate_function
(string $function, string $arguments, string $node)
-
string
$function: Name of the function to be evaluated.
-
string
$arguments: String containing the arguments being passed to the function.
-
string
$node: Full path to the document node on which the function should be evaluated.
Evaluates a predicate on a node.
This method tries to evaluate a predicate on a given node.
mixed
evaluate_predicate
(string $node, string $predicate)
-
string
$node: Full path of the node on which the predicate should be evaluated.
-
string
$predicate: String containing the predicate expression to be evaluated.
Evaluates a step of an XPath expression.
This method tries to evaluate a step from an XPath expression at a specific context.
array
evaluate_step
(string $context, array $steps)
-
string
$context: Full document path of the context from which starting the step should be evaluated.
-
array
$steps: Array containing the remaining steps of the current XPath expression.
void
getInstance
([mixed $name = "defaultXML"])
void
get_attribute
(mixed $path, mixed $attribute)
Retrieves a list of all attributes of a node.
This method retrieves a list of all attributes of the node specified in the argument.
array
get_attributes
(string $path)
-
string
$path: Full document path of the node, from which the list of attributes should be retrieved.
Retrieves axis information from an XPath expression step.
This method tries to extract the name of the axis and its node-test from a given step of an XPath expression at a given node.
array
get_axis
(string $step, string $node)
-
string
$step: String containing a step of an XPath expression.
-
string
$node: Full document path of the node on which the step is executed.
Retrieves the content of a node.
This method retrieves the content of a node. If it's an attribute node, then the value of the attribute will be retrieved, otherwise it'll be the character data of the node.
string
get_content
(string $path)
-
string
$path: Full document path of the node, from which the content should be retrieved.
Generates a XML file with the content of the current document.
This method creates a string containing the XML data being read and modified by this class before. This string can be used to save a modified document back to a file or doing other nice things with it.
string
get_file
([array $highlight = array()], [string $root = ""], int $level)
-
array
$highlight: Array containing a list of full document paths of nodes to be highlighted by <font>...</font> tags in the generated XML string.
-
string
$root: While doing a recursion with this method, this parameter is used for internal purpose.
-
int
$level: While doing a recursion with this method, this parameter is used for internal purpose.
Retrieves the name of a document node.
This method retrieves the name of document node specified in the argument.
string
get_name
(string $path)
-
string
$path: Full document path of the node, from which the name should be retrieved.
Handles the XPath ancestor axis.
This method handles the XPath ancestor axis.
array
handle_axis_ancestor
(array $axis, string $context)
-
array
$axis: Array containing information about the axis.
-
string
$context: Node from which starting the axis should be processed.
Handles the XPath ancestor-or-self axis.
This method handles the XPath ancestor-or-self axis.
array
handle_axis_ancestor_or_self
(array $axis, string $context)
-
array
$axis: Array containing information about the axis.
-
string
$context: Node from which starting the axis should be processed.
Handles the XPath attribute axis.
This method handles the XPath attribute axis.
array
handle_axis_attribute
(array $axis, string $context)
-
array
$axis: Array containing information about the axis.
-
string
$context: Node from which starting the axis should be processed.
Handles the XPath child axis.
This method handles the XPath child axis.
array
handle_axis_child
(array $axis, string $context)
-
array
$axis: Array containing information about the axis.
-
string
$context: Node from which starting the axis should be processed.
Handles the XPath descendant axis.
This method handles the XPath descendant axis.
array
handle_axis_descendant
(array $axis, string $context)
-
array
$axis: Array containing information about the axis.
-
string
$context: Node from which starting the axis should be processed.
Handles the XPath descendant-or-self axis.
This method handles the XPath descendant-or-self axis.
array
handle_axis_descendant_or_self
(array $axis, string $context)
-
array
$axis: Array containing information about the axis.
-
string
$context: Node from which starting the axis should be processed.
Handles the XPath following axis.
This method handles the XPath following axis.
array
handle_axis_following
(array $axis, string $context)
-
array
$axis: Array containing information about the axis.
-
string
$context: Node from which starting the axis should be processed.
Handles the XPath following-sibling axis.
This method handles the XPath following-sibling axis.
array
handle_axis_following_sibling
(array $axis, string $context)
-
array
$axis: Array containing information about the axis.
-
string
$context: Node from which starting the axis should be processed.
Handles the XPath namespace axis.
This method handles the XPath namespace axis.
array
handle_axis_namespace
(array $axis, string $context)
-
array
$axis: Array containing information about the axis.
-
string
$context: Node from which starting the axis should be processed.
Handles the XPath parent axis.
This method handles the XPath parent axis.
array
handle_axis_parent
(array $axis, string $context)
-
array
$axis: Array containing information about the axis.
-
string
$context: Node from which starting the axis should be processed.
Handles the XPath preceding axis.
This method handles the XPath preceding axis.
array
handle_axis_preceding
(array $axis, string $context)
-
array
$axis: Array containing information about the axis.
-
string
$context: Node from which starting the axis should be processed.
Handles the XPath preceding-sibling axis.
This method handles the XPath preceding-sibling axis.
array
handle_axis_preceding_sibling
(array $axis, string $context)
-
array
$axis: Array containing information about the axis.
-
string
$context: Node from which starting the axis should be processed.
Handles the XPath self axis.
This method handles the XPath self axis.
array
handle_axis_self
(array $axis, string $context)
-
array
$axis: Array containing information about the axis.
-
string
$context: Node from which starting the axis should be processed.
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.
void
handle_character_data
(int $parser, string $text)
-
int
$parser: Handler for accessing the current XML parser.
-
string
$text: Character data found in the document.
Handles closing XML tags while parsing.
While parsing a XML document for each closing tag this method is called.
void
handle_end_element
(int $parser, string $name)
-
int
$parser: Handler for accessing the current XML parser.
-
string
$name: Name of the closing tag found in the document.
Handles the XPath function boolean.
This method handles the XPath function boolean.
mixed
handle_function_boolean
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function ceiling.
This method handles the XPath function ceiling.
mixed
handle_function_ceiling
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function concat.
This method handles the XPath function concat.
mixed
handle_function_concat
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function contains.
This method handles the XPath function contains.
mixed
handle_function_contains
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function count.
This method handles the XPath function count.
mixed
handle_function_count
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function false.
This method handles the XPath function false.
mixed
handle_function_false
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function floor.
This method handles the XPath function floor.
mixed
handle_function_floor
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function id.
This method handles the XPath function id.
mixed
handle_function_id
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function lang.
This method handles the XPath function lang.
mixed
handle_function_lang
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function last.
This method handles the XPath function last.
mixed
handle_function_last
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function name.
This method handles the XPath function name.
mixed
handle_function_name
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function not.
This method handles the XPath function not.
mixed
handle_function_not
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function number.
This method handles the XPath function number.
mixed
handle_function_number
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function position.
This method handles the XPath function position.
mixed
handle_function_position
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function round.
This method handles the XPath function round.
mixed
handle_function_round
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function starts-with.
This method handles the XPath function starts-with.
mixed
handle_function_starts_with
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function string.
This method handles the XPath function string.
mixed
handle_function_string
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function string-length.
This method handles the XPath function string-length.
mixed
handle_function_string_length
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function substring.
This method handles the XPath function substring.
mixed
handle_function_substring
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function substring-after.
This method handles the XPath function substring-after.
mixed
handle_function_substring_after
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function substring-before.
This method handles the XPath function substring-before.
mixed
handle_function_substring_before
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function sum.
This method handles the XPath function sum.
mixed
handle_function_sum
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function text.
This method handles the XPath function text.
mixed
handle_function_text
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function translate.
This method handles the XPath function translate.
mixed
handle_function_translate
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
Handles the XPath function true.
This method handles the XPath function true.
mixed
handle_function_true
(string $node, string $arguments)
-
string
$node: Full path of the node on which the function should be processed.
-
string
$arguments: String containing the arguments that were passed to the function.
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.
void
handle_start_element
(int $parser, string $name, array $attributes)
-
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.
Checks for a valid function name.
This method check whether an expression contains a valid name of an XPath function.
boolean
is_function
(string $expression)
-
string
$expression: Name of the function to be checked.
Reads a file and parses the XML data.
This method reads the content of a XML file, tries to parse its content and upon success stores the information retrieved from the file into an array.
void
load_file
(string $file)
-
string
$file: Path and name of the file to be read and parsed.
Retrieves a substring before a delimiter.
This method retrieves everything from a string before a given delimiter, not including the delimiter.
string
prestr
(string $string, string $delimiter)
-
string
$string: String, from which the substring should be extracted.
-
string
$delimiter: String containing the delimiter to use.
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.
void
remove_node
(string $node)
-
string
$node: Full path of the node to be removed.
Looks for a string within another string.
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.
int
search_string
(string $term, string $expression)
-
string
$term: String in which the search shall take place.
-
string
$expression: String that should be searched.
Sets the attributes of a node.
This method sets the attributes of a node and overwrites all existing attributes by doing this.
void
set_attributes
(string $path, array $attributes)
-
string
$path: Full document path of the node, the attributes of which should be set.
-
array
$attributes: Associative array containing the new attributes for the node.
Set the content of a node.
This method sets the content of a node. If it's an attribute node, then the value of the attribute will be set, otherwise the character data of the node will be set. Existing content will be overwritten.
void
set_content
(string $path, string $value)
-
string
$path: Full document path of the node.
-
string
$value: String containing the content to be set.
Splits an XPath expression into its different expressions.
This method splits an XPath expression. Each expression can consists of list of expression being separated from each other by a | character.
array
split_paths
(string $expression)
-
string
$expression: The complete expression to be splitted into its different expressions.
Splits an XPath expression into its different steps.
This method splits an XPath expression. Each expression can consists of list of steps being separated from each other by a / character.
array
split_steps
(string $expression)
-
string
$expression: The complete expression to be splitted into its different steps.