Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Parse the NETCONF Server Response in Perl Client Applications

After establishing a connection to a NETCONF server, a NETCONF Perl client application can submit one or more requests by invoking Perl methods. The NETCONF server returns the appropriate information in an <rpc-reply> element. There are two ways of parsing the NETCONF server’s response:

  • By using functions of XML::LibXML::DOM

  • By using functions of XML::LibXML::XPATHContext

For example, consider the following reply from a NETCONF server:

Suppose the user wants to parse the response and retrieve the value of the <serial-number> element.

The following code uses XML::LibXMl::DOM to retrieve the value. The example stores the response in a variable and calls methods of DOM to parse the response.

The following code uses XML::LibXML::XPATHContext to retrieve the value. The example stores the response in a variable and calls XPathContext methods to retrieve the value. The local-name() function returns the element name without the namespace. The XPATH expression appears on multiple lines for readability.