XdmNode navigation
The XdmNode
class provides DOM like methods to navigate nodes in a tree. The options
available in the C++, Python and PHP APIs are as follows:
-
In the C++ and Python APIs, simple navigation down the tree can be achieved using the
getChildren()
method (orchildren
property in Python) which returns all the child nodes at a given parent node.For PHP, navigate down the tree using the
getChildNode()
method, which requires an integer index argument, and returns the i'th child node (use thegetChildCount()
method to get the number of child nodes).Use the method
getParent()
(get_parent()
in Python) to navigate back up the tree, and the methodsgetAttributeNodes()
andgetAttributeValue(name)
(attributes
property andget_attribute_value(name)
in Python) to retrieve the attribute nodes and their values. -
Since SaxonC 12.3, as an alternative to the above, the
axisNodes()
method (axis_nodes()
in Python) is available which provides navigation of the tree using the XPath axes. The axis options are: ANCESTOR, ANCESTOR_OR_SELF, ATTRIBUTE, CHILD, DESCENDANT, DESCENDANT_OR_SELF, FOLLOWING, FOLLOWING_SIBLING, NAMESPACE, PARENT, PRECEDING, PRECEDING_SIBLING and SELF.
For more information and other methods, see the API documentation: