I have the following code snippet in a Gradle script (the syntax is a combination of Groovy/Java):
File file = new File(filename) // Filename is being read from console
def content = file.getText()
Document document = DOMBuilder.parse(new StringReader(content), false, false)
The problem is, I'm trying to parse an XML file, but with a xconf
extension (e.g. file.xconf
). For some reason or another, when I try the code above, I get the following error message (in the console):
java.io.FileNotFoundException: <full_path>/file.dtd (No such file or directory)
The path is correct, but I noticed the extension is suddenly being changed to .dtd
.
I noticed in the file there's a reference to the .dtd
version of that file, but I want the parser to ignore that (and stop validation, which is why the 2nd argument of DOMBuilder.parse()
is false). Can I change this behavior to be able to succesfully parse the file?
Note: If possible, I would also like to be able to do the same with (any) other file extension.
Thanks in advance!