Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 84089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:52:34+00:00 2026-05-10T21:52:34+00:00

I got dtd in file and I cant remove it. When i try to

  • 0

I got dtd in file and I cant remove it. When i try to parse it in Java I get ‘Caused by: java.net.SocketException: Network is unreachable: connect’, because its remote dtd. can I disable somehow dtd checking?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T21:52:34+00:00Added an answer on May 10, 2026 at 9:52 pm

    You should be able to specify your own EntityResolver, or use specific features of your parser? See here for some approaches.

    A more complete example:

    <?xml version='1.0'?> <!DOCTYPE foo PUBLIC '//FOO//' 'foo.dtd'> <foo>     <bar>Value</bar> </foo> 

    And xpath usage:

    import java.io.File; import java.io.IOException; import java.io.StringReader;  import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathFactory;  import org.w3c.dom.Document; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; import org.xml.sax.SAXException;  public class Main {      public static void main(String[] args) throws Exception {         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();         DocumentBuilder builder = factory.newDocumentBuilder();          builder.setEntityResolver(new EntityResolver() {              @Override             public InputSource resolveEntity(String publicId, String systemId)                     throws SAXException, IOException {                 System.out.println('Ignoring ' + publicId + ', ' + systemId);                 return new InputSource(new StringReader(''));             }         });         Document document = builder.parse(new File('src/foo.xml'));         XPathFactory xpathFactory = XPathFactory.newInstance();         XPath xpath = xpathFactory.newXPath();         String content = xpath.evaluate('/foo/bar/text()', document                 .getDocumentElement());         System.out.println(content);     } } 

    Hope this helps…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got 5 files 3 xml and 2 java (to connect and execute HQL
Got a problem with ADOMD.NET 8.0, SQL2008 and our app. It isn't giving us
I've got a .jsp file that is working fine. It's maybe a bit special
I've got the following JNLP: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE jnlp PUBLIC -//Sun Microsystems, Inc//DTD
Has anyone got EclipseLink MOXy (I'm using eclipselink 2.1.0) to work with Java 5?
I've got HTML code like this: <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
Hi I got the following code: <?xml version=1.0 encoding=UTF-8 ?> <!DOCTYPE html PUBLIC -//W3C//DTD
Got a bluescreen in windows while cloning a mercurial repository. After reboot, I now
got a new blog at wordpress few days ago ( http://ghads.wordpress.com ) and I
Got a class that serializes into xml with XMLEncoder nicely with all the variables

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.