I try to open a XML-file out of a zip-file (docx). Therefore I'm using ZipArchive and XMLReader. But I think I'm doing something wrong.
The docx-file is named example.docx and I need to open the file word/document.xml via XMLReader.
I would be very happy if someone may correct my little script:
$zip = new ZipArchive;
$filename = "example.docx";
if(!$filename || !file_exists($filename)) return false;
$zip = zip_open($filename);
$reader = new XMLReader;
if (!$reader->open($zip->getFromIndex(3))) { //should be "word/document.xml"
die("Failed to open file");
}
$zip->close();
With this code I always get "Failed to open file".
No comments:
Post a Comment