I'm trying to parse an xml file using 'DocumentBuilder' and got following error.
java.net.MalformedURLException: no protocol: <http://java.sun.com/j2ee/dtds/application_1_2.dtd>
First part of my xml file is like this (XML file cannot be changed)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN' '<http://java.sun.com/j2ee/dtds/application_1_2.dtd>'>
<application>
<display-name>Black hole</display-name>
<description>Black hole service framework</description>
<module>
<ejb>StructureService.jar</ejb>
</module>
<module>
<ejb>ResourceService.jar</ejb>
</module>
<module>
<ejb>DatumServiceInternal.jar</ejb>
</module>
Here, How I tried to parse the XML file
File xml = new File(path);
FileInputStream inputStream = new FileInputStream(xml);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
return db.parse(inputStream , "UTF-8");
I tried to do it different ways, but I got above error constantly. Please help me to find the problem.