Use DOM4J to parse a custom. xml file.
The general contents are as follows:
XML code
<?xml version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE plist Public "-//apple//dtd plist 1.0//en" "Http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
<plist version= "1.0" >
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<key>kind</key>
<string>software-package</string>
<key>url</key>
<string>appPath</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>appIdentifier</string>
<key>bundle-version</key>
<string>appVersion</string>
<key>kind</key>
<string>software</string>
<key>title</key>
<string>appName</string>
</dict>
</dict>
</array>
</dict>
</plist>
Actually reported a connection timeout error:
Org.dom4j.DocumentException:Connection timed Out:connect Nested exception:connection timed Out:connect
At Org.dom4j.io.SAXReader.read (saxreader.java:484)
At Org.dom4j.io.SAXReader.read (saxreader.java:321)
At Com.util.ReadXmlDataUtil.getLanguageXMLData (readxmldatautil.java:28)
At Com.admin.util.ReadXmlDataUtil.main (readxmldatautil.java:50)
Nested Exception:
Java.net.ConnectException:Connection timed Out:connect
At Java.net.PlainSocketImpl.socketConnect (Native Method)
At Java.net.PlainSocketImpl.doConnect (plainsocketimpl.java:333)
At Java.net.PlainSocketImpl.connectToAddress (plainsocketimpl.java:195)
At Java.net.PlainSocketImpl.connect (plainsocketimpl.java:182)
At Java.net.SocksSocketImpl.connect (sockssocketimpl.java:366)
At Java.net.Socket.connect (socket.java:519)
At Java.net.Socket.connect (socket.java:469)
At Sun.net.NetworkClient.doConnect (networkclient.java:163)
At Sun.net.www.http.HttpClient.openServer (httpclient.java:394)
At Com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse (abstractsaxparser.java:1205)
At Com.sun.org.apache.xerces.internal.jaxp.saxparserimpl$jaxpsaxparser.parse (saxparserimpl.java:522)
At Org.dom4j.io.SAXReader.read (saxreader.java:465)
At Org.dom4j.io.SAXReader.read (saxreader.java:321)
At Com.huawei.ngbss.admin.util.ReadXmlDataUtil.getLanguageXMLData (readxmldatautil.java:28)
At Com.huawei.ngbss.admin.util.ReadXmlDataUtil.main (readxmldatautil.java:50)
Nested exception:java.net.ConnectException:Connection timed Out:connect
At Java.net.PlainSocketImpl.socketConnect (Native Method)
At Java.net.PlainSocketImpl.doConnect (plainsocketimpl.java:333)
Solution:
The reason behind this is found:
Is the problem of the network, because the connection of DOCTYPE is caused by different.
<! DOCTYPE plist Public "-//apple//dtd plist 1.0//en" "Http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
When the Saxreader parser is used, the contents of the DOCTYPE are automatically parsed. If the connection is not on the network, the connection timeout exception is reported.
So in order to, otherwise parse doctype, then reader.setfeature (do not load DTD file, false); will not be able to parse the DOCTYPE.
Can.
Saxreader reader = new Saxreader ();
Reader.setfeature ("Http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
Connection timed Out:connect Nested exception