Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

NETCONF Java Toolkit Class: XMLBuilder

In a NETCONF session, communication between the configuration management server and the NETCONF server is through XML-encoded data. The configuration management server sends remote procedure calls (RPCs) to the NETCONF server, and the NETCONF server processes the RPC and returns an RPC reply. The net.juniper.netconf.XMLBuilder and net.juniper.netconf.XML objects help create and parse XML-encoded data.

You use the XMLBuilder object to create a new XML object. The constructor syntax is:

XMLBuilder ()

The XMLBuilder class includes methods to create a configuration hierarchy, an RPC, or an XML object as XML-encoded data. Each method is overloaded to accept multiple hierarchy levels. The methods return an XML object. For example, the methods to construct a configuration, RPC, or XML object with a single-tier hierarchy are:

  • createNewConfig(String elementLevelOne)
  • createNewRPC(String elementLevelOne)
  • createNewXML(String elementLevelOne)

The following sample code creates a new XMLBuilder object, builder. The XMLBuilder object calls the createNewConfig() method to construct a three-tier configuration hierarchy consisting of a “security” element, a “policies” element child tag, and a “policy” element that is a child of “policies”.

XMLBuilder builder = new XMLBuilder();
XML policy = builder.createNewConfig("security","policies","policy");

The resulting XML hierarchy is as follows.

<configuration>
    <security>
        <policies>
            <policy>
            </policy>
        </policies>
    </security>
</configuration>

Notice that the createNewConfig() method always encloses the hierarchy within a top-level root element <configuration>. Similarly, the createNewRPC() method encloses the hierarchy within an <rpc> tag element.

Once you generate an XML object, you can call methods from the XML class to manipulate that object.

Published: 2013-07-26