<p>The XML file I want to parse starts with  :</p>

<pre><code>&lt;!DOCTYPE plist PUBLIC "-//...//DTD PLIST 1.0//EN" "http://www.....dtd"&gt;
</code></pre>

<p>So when I start the SAX praser, it tries to access this DTD online, and I get a java.net.UnknownHostException.</p>

<ol>
<li>I cannot modify the XML file before feeding it to the SAX parser</li>
<li>I have to run even with no internet connection</li>
</ol>

<p>How can I change the SAX Parser behaviour so that it does not try to load the DTD ?
Thanks.</p>

<pre><code>javax.xml.parsers.SAXParserFactory factory = javax.xml.parsers.SAXParserFactory.newInstance();
factory.setValidating(false);

javax.xml.parsers.SAXParser parser = factory.newSAXParser();
parser.parse(xmlFile, handler);
</code></pre>

You can implement a custom
```
EntityResolver
```
which is what is used to lookup external entities during XML parsing.
```
```
org.xml.sax.EntityResolver customEntityResolver = new DummyEntityResolver();
javax.xml.parsers.SAXParser parser = factory.newSAXParser();
parser.getXMLReader().setEntityResolver(customEntityResolver);
parser.parse(xmlFile, handler);
```
```
And in your custom EntityResolver, just always return null. I think that should fix this problem.