Location paths are used to extract data from an XML structure. They follow a fixed syntax that dictates which nodes should be retrieved and included within the output. The results of a location path are communicated as a node-set that can be assigned to a variable or used within a SLAX statement such as if or for-each.

Using location paths is similar to locating files within a file system. The search starts at a particular reference point and the use of the forward slash / indicates that the search path will move to a child of the current reference point. As an example, assume that $result is the name of the node-set variable which has been assigned the XML result of <get-system-uptime-information>. If the boot-time value is desired then it can be retrieved with the following location-path:
$results/system-booted-time/date-time

This element node could be assigned to another variable:
var $date-time = $results/system-booted-time/date-time;

Or the text value of the date-time element node could be output to the console:
<output> $results/system-booted-time/date-time;

Reviewing the location path shown above, $results has a default reference point of the <system-uptime-information> element node. This is the starting context node from which all location paths defined using this variable are based.

version 1.0;

ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";

import "../import/junos.xsl";

match / {
    <op-script-results> {
        var $results = jcs:invoke( "get-system-uptime-information" );
        <output> $results/system-booted-time/date-time;
    }
}