Solve the problem of java.net.malformedurlexception: unknown protocol: C

Code before modification:

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(xmlPath);\\ Direct the path name to the builder.

After the change:

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse("file:///" + xmlPath);

 

Similar Posts: