How to read xml file using PHP
Hello,
my question may be seems simple but what i really meant is that i have unzipped a pptx file and i m trying to read the xml using php ... here is my code .
i just got a "done (unzipped succeeded)" output and nothing else
PHP Code:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// the string variable that will hold the file content
$file_content = "";
// open file
$file_path = './Reports/report.pptx';
$target_folder_path = './Reports/';
$zip = new ZipArchive;
$res = $zip->open($file_path);
if ($res === TRUE) {
$zip->extractTo($target_folder_path);
//$zip->close();
echo 'done <br>';
// loop through all slide#.xml files
$slide = 1;
while ( ($index = $zip -> locateName("./Reports/ppt/slides/" . $slide . ".xml")) !== false ){
$data = $zip -> getFromIndex($index);
$xml = DOMDocument::loadXML($data, LIBXML_NOENT | LIBXML_XINCLUDE | LIBXML_NOERROR | LIBXML_NOWARNING);
$file_content .= strip_tags($xml -> saveXML());
$slide++;
}
$zip->close();
} else {
echo 'failed';
}
echo $file_content;
//var_dump($file_content);
?>
Thanks in advance
Karl