import java.io.File; import java.io.IOException; import java.io.PrintStream; import java.io.FileInputStream; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.DocumentBuilder; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.w3c.dom.Document; import org.w3c.dom.DOMException; /** * read a hosts xml doc in and pick out the necessary bits of info */ public class hostinfo { protected static String hostname = ""; protected static String label = ""; protected static String mapname = ""; protected static String hosttype = ""; protected static String pollenabled = ""; protected static String polltype = ""; protected static String logging = ""; protected static String notify = ""; protected static String servicegroup = ""; protected static String dependencyup = ""; protected static String dependencydown = ""; protected static String schedulestart = ""; protected static String scheduleend = ""; protected static String scheduledays = ""; protected static String snmpenabled = ""; protected static String snmpread = ""; protected static String snmpwrite = ""; protected static String snmpobjectid = ""; protected static String contact = ""; protected static String address = ""; protected static String city = ""; protected static String state = ""; protected static String zip = ""; protected static String notes = ""; String getDataFromNode( org.w3c.dom.Node nod ) { org.w3c.dom.NodeList nodes = nod.getChildNodes(); for ( int i=0; i< nodes.getLength(); i++ ) { org.w3c.dom.Node node = nodes.item(i); int type = node.getNodeType(); String val = node.getNodeValue(); String name = node.getNodeName(); if ( type == 3 ) { if ( val != null ) { return( val ); } } } return( "" ); } String getDataFromNode( org.w3c.dom.Node nod, String str ) { org.w3c.dom.NodeList nodes = nod.getChildNodes(); for ( int i=0; i< nodes.getLength(); i++ ) { org.w3c.dom.Node node = nodes.item(i); int type = node.getNodeType(); String val = node.getNodeValue(); String name = node.getNodeName(); if ( type == 1 && name != null ) { if ( name.equals( str )) { if ( node.hasChildNodes() ) { org.w3c.dom.NodeList nads = node.getChildNodes(); for ( int j = 0; j < nads.getLength(); j++ ) { node = nads.item(j); type = node.getNodeType(); val = node.getNodeValue(); name = node.getNodeName(); if ( type == 3 && val != null ) { return( val ); } } } } } } return( "" ); } void recurseNodes( org.w3c.dom.NodeList nodes ) throws IOException { for (int i=0; i