Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Mapping Junos OS Commands and Command Output to Junos XML Tag Elements


The Junos XML API is an XML representation of Junos OS configuration statements and operational mode commands. It defines an XML equivalent for all statements in the Junos OS configuration hierarchy and many of the commands that you issue in CLI operational mode. Each operational mode command with a Junos XML counterpart maps to a request tag element and, if necessary, a response tag element.

Request tag elements are used in remote procedure calls (RPCs) within NETCONF and Junos XML protocol sessions to request information from a device running Junos OS. The server returns the response using Junos XML tag elements enclosed within the response tag element. For example, the show interfaces command maps to the <get-interface-information> request tag, and the server returns the <interface-information> response tag.

The following sections outline how to map commands, command options, and command output to Junos XML tag elements.

Mapping Command Output to Junos XML Elements

On the Junos OS command-line interface (CLI), to display command output as Junos XML tag elements instead of as the default formatted ASCII text, include the | display xml option after the command. The tag elements that describe the Junos OS configuration or operational data belong to the Junos XML API, which defines the Junos OS content that can be retrieved and manipulated by NETCONF and Junos XML management protocol operations.

The following example shows the output from the show chassis hardware command issued on an M20 router that is running Junos OS Release 9.3 (the opening <chassis-inventory> tag appears on two lines only for legibility). This is identical to the server’s response for the <get-chassis-inventory> RPC request.

user@host> show chassis hardware | display xml

Mapping Commands to Junos XML Request Tag Elements

Information about the available command equivalents in the current release of the Junos OS can be found in the Junos XML API Operational Developer Reference. For the mapping between commands and Junos XML tag elements, see the Junos XML API Operational Developer Reference “Mapping Between Operational Tag Elements, Perl Methods, and CLI Commands” chapter. For detailed information about a specific operation, see the Junos XML API Operational Developer Reference “Summary of Operational Request Tags” chapter.

On the Junos OS CLI, you can display the Junos XML request tag elements for any operational mode command that has a Junos XML counterpart. To display the Junos XML RPC request tags for an operational mode command, include the | display xml rpc option after the command.

The following example displays the RPC tags for the show route command:

user@host> show route | display xml rpc

Mapping for Command Options with Variable Values

Many CLI commands have options that identify the object that the command affects or reports about, distinguishing the object from other objects of the same type. In some cases, the CLI does not precede the identifier with a fixed-form keyword, but XML convention requires that the Junos XML API define a tag element for every option. To learn the names for each identifier (and any other child tag elements) for an operational request tag element, consult the tag element’s entry in the appropriate DTD or in the Junos XML API Operational Developer Reference, or issue the command and command option in the CLI and append the | display xml rpc option.

The following example shows the Junos XML tag elements for two CLI operational commands that have variable-form options. In the show interfaces command, t3-5/1/0:0 is the name of the interface. In the show bgp neighbor command, is the IP address for the BGP peer of interest.

You can display the Junos XML RPC tags for a command and its options in the CLI by executing the command and command option and appending | display xml rpc.

user@host> show interfaces t3-5/1/0:0 | display xml rpc

Mapping for Fixed-Form Command Options

Some CLI commands include options that have a fixed form, such as the brief and detail strings, which specify the amount of detail to include in the output. The Junos XML API usually maps such an option to an empty tag whose name matches the option name.

The following example shows the Junos XML tag elements for the show isis adjacency command, which has a fixed-form option called detail:

To view the tags in the CLI:

user@host> show isis adjacency detail | display xml rpc