Getting document.xml from a docx file using ZipInputStream

Posted by meenakshik on Stack Overflow See other posts from Stack Overflow or by meenakshik
Published on 2010-05-06T08:44:30Z Indexed on 2010/05/06 8:48 UTC
Read the original article Hit count: 608

Filed under:
|
|
|

Hello,

I have a inputStream of a docx file and I need to get hold of the document.xml which lies inside the docx.

I am using ZipInputStream to read my stream and my code is something like

    ZipInputStream docXFile = new ZipInputStream(fileName);
    ZipEntry zipEntry;
    while ((zipEntry = docXFile.getNextEntry()) != null) {
        if(zipEntry.getName().equals("word/document.xml"))
        {
            System.out.println(" --> zip Entry is "+zipEntry.getName());
        } 
    }

As you can see The output for zipEntry.getName comes as "word/document.xml" at some point. I need to pass this document.xml as a stream and unlike the ZipFile method where you can easily pass this on calling .getInputStream, I am wondering how can I do this docXFile?

Thanks in advance, Meenakshi

© Stack Overflow or respective owner

Related posts about java

Related posts about docx