Hi!, while parsing an xml file, I am getting error that it is not able to resolve a url
(eg: <!DOCTYPE RootElement SYSTEM "http://www.mywebsite.com:80/dtds/testdtd_200609.dtd">. When I googled, there were suggestions that I need to use EntityResolver. But it is not working. Here is the code that I have.
Ant help is greatly appreciated.
Regards
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
docBuilder.setEntityResolver(new EntityResolver() {
public InputSource resolveEntity(java.lang.String publicId,
java.lang.String systemId)
throws SAXException, java.io.IOException {
if (publicId.equals("--myDTDpublicID-"))
return new InputSource(new ByteArrayInputStream
("<?xml version='1.0' encoding='UTF-8'?>".getBytes()));
else return null;
}
});