Ignore DTD specification in scala
This works for me, but it depends on the implementation of the XML parser.
import scala.xml.Elemimport scala.xml.factory.XMLLoaderimport javax.xml.parsers.SAXParserobject MyXML extends XMLLoader[Elem] { override def parser: SAXParser = { val f = javax.xml.parsers.SAXParserFactory.newInstance() f.setNamespaceAware(false) f.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); f.newSAXParser() }}
See also this question, which is really your question but worded in a hostile way.
The first answer doesn't work when we have incorrect DOCTYPE in xml file.My solution is:
import scala.xml.Elemimport scala.xml.factory.XMLLoaderimport javax.xml.parsers.SAXParserobject XML extends XMLLoader[Elem] { override def parser: SAXParser = { val f = javax.xml.parsers.SAXParserFactory.newInstance() f.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); f.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); f.newSAXParser() }}