how to disable dtd at runtime in java's xpath?

后端 未结 3 1704
悲&欢浪女
悲&欢浪女 2020-12-01 16:30

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

3条回答
  •  长情又很酷
    2020-12-01 17:25

    I had this problem before. I solved it by downloading and storing a local copy of the DTD and then validating against the local copy. You need to edit the XML file to point to the local copy.

    
    

    Little more info here: http://www.w3schools.com/dtd/dtd_intro.asp

    I think you can also manually set some sort of validateOnParse property to "false" in your parser. Depends on what library you're using to parse the XML.

    More info here: http://www.w3schools.com/dtd/dtd_validation.asp

提交回复
热议问题