From the course: PHP: Exporting Data to Files

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Extracting the main content file from a Word document

Extracting the main content file from a Word document - PHP Tutorial

From the course: PHP: Exporting Data to Files

Start my 1-month free trial

Extracting the main content file from a Word document

The docx file, that we've just created, is basically a wrapper for a collection of XML and other files bundled together using Zip compression. To create a download file incorporating the database results, we need to extract the main XML file and convert it into an XSLT stylesheet. As in the previous chapter, we'll use a PHP script to do this. But first, let's take a look inside the docx file to see how its structure differs from that of an open document text file. So here's flowers_wordTemplate.docx. If you want to follow along make sure the file is no longer open in Microsoft Word, navigate to the output folder in Windows Explorer or Mac Finder. Unlike the ODT file in previous chapter, changing the file name extension of a docx file to zip and back again doesn't seem to corrupt it on a Mac. So let's change this from docx to zip. We're warned that it might become unusable. That's no problem, and then, we need to unzip it. So, right click, I'm going to use Win Zip. You can use any…

Contents