Getting the Root Node

In order to access the root node a session needs to be started.

All content added to the PCR will be children Nodes of the Root Node.

The following code assigns the Root Node to the $node variable:

<?php 
$node = $session->getRootNode();

echo $node->getName(); //outputs pcr:root
?>

Getting Nodes

If the absolute path to a Node is known, the session can be used to retrieve Nodes as well as Properties:

<?php 
$node = $session->getItem('pcr:root/users/jsmith')->toNode();

//the code above is an alternative to the following:
$node = $session->getRootNode();
$node = $node->getNode('users/jsmith');
?>

Getting Children Nodes

Retrieving all Children Nodes from a Parent Node will return a NodeIterator:

<?php 
//populate test data
$node = $session->getRootNode();
$node = $node->addNode('users');
$node->addNode('jsmith');
$node->addNode('asmith');
$node->addNode('bsmith');
$node->addNode('csmith');

echo 'Getting children nodes for ' . $node->getPath() . '<br />';

$ni = $node->getNodes();

while ($ni->hasNext()) {
  $temporaryNode = $ni->nextNode();
  echo $temporaryNode->getPath() . ' is a child of ' . 
       $node->getPath() . '<br />';
}
?>