Junos scripts can retrieve the current configuration by sending the <get-configuration> API Element to jcs:invoke():
var $configuration = jcs:invoke( "get-configuration" );

There are a number of attributes available for <get-configuration>, the most useful of which is database. It can be set to either committed or candidate, and it indicates which configuration database should be returned. The candidate database is returned by default if the database attribute is missing.
var $rpc = <get-configuration database="committed">;
var $committed-configuration = jcs:invoke( $rpc );

When the script requires only portions of the configuration then specify those hierarchies within <get configuration>:
var $rpc = <get-configuration database="committed"> {
    <configuration> {
        <protocols> {

Configuration settings can be retrieved through location paths in the same way as operational results. This example shows how to do it.

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> {
        /* Junos XML API Element to retrieve the configuration */
        var $config-rpc = <get-configuration> {
            <configuration> {
        /* Request configuration and assign to $config variable */
        var $config = jcs:invoke( $config-rpc );
        /* Extract the name-servers from the config and assign to variable */
        var $name-servers = $config/system/name-server;
        * If no name-servers are present then output message, otherwise
        * output all the name-server names/addresses.
        if( jcs:empty( $name-servers ) ) {
            <output> "There are no name servers defined.";
        else {
            <output> "Here are the name-servers:";
            for-each( $name-servers ) {
                <output> ./name;