in Education by
I am using a third party application and would like to change one of its files. The file is stored in XML but with an invalid doctype. When I try to read use a it errors out becuase the doctype contains "file:///ReportWiz.dtd" (as shown, with quotes) and I get an exception for cannot find file. Is there a way to tell the docbuilder to ignore this? I have tried setValidate to false and setNamespaceAware to false for the DocumentBuilderFactory. The only solutions I can think of are copy file line by line into a new file, omitting the offending line, doing what i need to do, then copying into another new file and inserting the offending line back in, or doing mostly the same above but working with a FileStream of some sort (though I am not clear on how I could do this..help?) DocumentBuilderFactory docFactory = DocumentBuilderFactory .newInstance(); docFactory.setValidating(false); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.parse(file); JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Tell your DocumentBuilderFactory to ignore the DTD declaration like this: docFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); See here for a list of available features. You also might find JDOM a lot easier to work with than org.w3c.dom: org.jdom.input.SAXBuilder builder = new SAXBuilder(); builder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); org.jdom.Document doc = builder.build(file);

Related questions

0 votes
    I am using a third party application and would like to change one of its files. The file is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I am using a third party application and would like to change one of its files. The file is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I am using a third party application and would like to change one of its files. The file is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 10, 2022 in Education by JackTerrance
0 votes
    I do alot of systems programming where my apps have no chance of being used to communicate over the web ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    I do alot of systems programming where my apps have no chance of being used to communicate over the web ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    I do alot of systems programming where my apps have no chance of being used to communicate over the web ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    I do alot of systems programming where my apps have no chance of being used to communicate over the web ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    I do alot of systems programming where my apps have no chance of being used to communicate over the web ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    I do alot of systems programming where my apps have no chance of being used to communicate over the web ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    I do alot of systems programming where my apps have no chance of being used to communicate over the web ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    I have millions of file in a Folder its difficult to read with script so i need to store file in ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    I'd like to create a keyboard shortcut (such as CTRL+T) that automatically moves the cursor to the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    I looked into the Python os interface, but was unable to locate a method to move a file. How ... mv source_files destination_folder Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
0 votes
    Which built-in function can be used to move the file pointer internally?...
asked Jan 18, 2021 in Technology by JackTerrance
+1 vote
    Which built-in function can be used to move the file pointer internally in C Programming?...
asked Nov 9, 2020 in Technology by JackTerrance
...