0

I'm parsing an XML file. I have code that deals with the file just fine...

DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);
// and so on

However, the XML file is delivered in a ZIP. I have to unZIP it and run my code on the .xml file. What I would like to do is run my code against the .ZIP directly. I have tried any number of things using the Java ZipFile object but just cannot get it to work. What code do I need to read the file directly out of the ZIP file?

  • If you've tried using `ZipFile` (which is the best way to do it, if you have the file on disk), then post your code and show where the problem is - people can try to help you then. See [mcve] – Erwin Bolwidt Jun 08 '18 at 01:53
  • Well, that's the problem - I have nothing that comes even close to working. I have looked at more ZipFile examples than I can count. What do I do to pull that XML file out of the zip and then feed it to my existing code? – John D. Goulden Jun 08 '18 at 01:59
  • Have you looked at the answers to the following question? They show various ways to access ZipFiles: https://stackoverflow.com/questions/15667125/read-content-from-files-which-are-inside-zip-file – Erwin Bolwidt Jun 08 '18 at 02:07
  • That did it, thanks. – John D. Goulden Jun 08 '18 at 06:22

0 Answers0