I created a document factory object and tried to parse an existing XML file....
Here is my code File xmlFile = new File("C:/jboss-config.xml"); DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.parse(xmlFile); int elementType = doc.getNodeType(); switch(elementType) { case Node.ELEMENT_NODE: { String nodeElement = doc.getNodeName() ; if(nodeElement.equals("policy")) { Element policyElement = doc.createElement("policy_new"); doc.appendChild(policyElement); break; } } } When I run the code I get the following error...... java.net.ConnectException: Operation timed out: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(Unknown Source) at java.net.PlainSocketImpl.connectToAddress(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.Socket.<init>(Unknown Source) at java.net.Socket.<init>(Unknown Source) at sun.net.NetworkClient.doConnect(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.openServer(Unknown Source) at sun.net.www.http.HttpClient.<init>(Unknown Source) at sun.net.www.http.HttpClient.<init>(Unknown Source) at sun.net.www.http.HttpClient.New(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at java.net.URL.openStream(Unknown Source) at weblogic.apache.xerces.readers.DefaultReaderFactory.createReader(DefaultReaderFactory.java:149) at weblogic.apache.xerces.readers.DefaultEntityHandler.startReadingFromExternalEntity(DefaultEntityHandler.java:786) at weblogic.apache.xerces.readers.DefaultEntityHandler.startReadingFromExternalSubset(DefaultEntityHandler.java:583) at weblogic.apache.xerces.framework.XMLDTDScanner.scanDoctypeDecl(XMLDTDScanner.java:1161) at weblogic.apache.xerces.framework.XMLDocumentScanner.scanDoctypeDecl(XMLDocumentScanner.java:2189) at weblogic.apache.xerces.framework.XMLDocumentScanner.access$0(XMLDocumentScanner.java:2143) at weblogic.apache.xerces.framework.XMLDocumentScanner$PrologDispatcher.dispatch(XMLDocumentScanner.java:856) at weblogic.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:399) at weblogic.apache.xerces.framework.XMLParser.parse(XMLParser.java:1147) at weblogic.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:203) at weblogic.xml.jaxp.RegistryDocumentBuilder.parse(RegistryDocumentBuilder.java:144) at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:161) Please help -- View this message in context: http://www.nabble.com/XML-parse-DOM-Connection-time-out-tp23760394p23760394.html Sent from the Apache XML - General mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: general-unsubscr...@xml.apache.org For additional commands, e-mail: general-h...@xml.apache.org