(String[] args)
| 20 | |
| 21 | public class parse_interface_info { |
| 22 | public static void main(String[] args) throws IOException, |
| 23 | SAXException { |
| 24 | |
| 25 | Device device = CreateDevice.createDevice(); |
| 26 | device.connect(); |
| 27 | |
| 28 | XML rpc_reply = device.executeRPC("get-interface-information"); |
| 29 | System.out.println(rpc_reply.toString()); |
| 30 | // Obtain a list of list of ‘org.w3c.dom.Node’ objects |
| 31 | List<String> list = Arrays.asList("interface-information","physical-interface"); |
| 32 | List physical_interfaces_list = rpc_reply.findNodes(list); |
| 33 | // Print the value for each of the name elements: |
| 34 | for (Object o : physical_interfaces_list) { |
| 35 | Node node = (Node) o; |
| 36 | NodeList child_nodes_of_phy_interface = node.getChildNodes(); |
| 37 | // child_nodes_of_phy_interface contains nodes like <name> and <admin-status> |
| 38 | // Get each <name> node from the NodeList |
| 39 | for (int i = 0; i < child_nodes_of_phy_interface.getLength(); i++) { |
| 40 | Node child_node = child_nodes_of_phy_interface.item(i); |
| 41 | if (child_node.getNodeType() != Node.ELEMENT_NODE) { |
| 42 | continue; |
| 43 | } |
| 44 | if (child_node.getNodeName().equals("name")) { // Print the text value of the <name> node |
| 45 | System.out.println(child_node.getTextContent()); |
| 46 | } |
| 47 | break; |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | } |
nothing calls this directly
no test coverage detected