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 .odt document - PHP Tutorial
From the course: PHP: Exporting Data to Files
Extracting the main content file from a .odt document
We need a new file for the script that ill extract content.xml and delete the placeholder image, so in your testing site, create a new PHP file, save it in the output folder as odt_extract.php. We need a couple of variables, one for the name of the template, the other for the name that you want to save content.xml as. The first one will be our sourcefile and that's flowers_odtTemplate. And, the other one is for our copy of content.xml, which will be saved as an XSLT file. So, XSLT equals and, we'll call that, flowers_odt.xslt. We know that an open document text file is really a zip file, so we can use the PHP zip class to extract content.xml and delete the placeholder image. And the interesting thing is we don't even need to change the file name extension from odt to zip, PHP will open in automatically. Zip equals new ZipArchive and we need to open it. So zip open file name is sourcefile and then if you know the name of the file that you want to extract, you can use the get from name…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
(Locked)
Creating a .odt file to use as a template4m 29s
-
(Locked)
Inspecting the structure of an OpenDocument text file2m 43s
-
(Locked)
Extracting the main content file from a .odt document5m 2s
-
(Locked)
Converting the main content file to XSLT8m 3s
-
(Locked)
Outputting the database result as a .odt file7m
-
(Locked)
-
-