Pergunta
Como você leria os arquivos ODT no PHP? Eu sei que você pode usar o QueryPath, mas isso parece um exagero, ... eu só quero ler o arquivo.
Solução
ODT, os arquivos são XML compactados com ZIP.
Se tudo o que você precisa fazer é ler o arquivo cru. Apenas descompacte e leia como um arquivo normal.
Se você precisar analisar o texto utilizável, insira a necessidade de consulsão ou algum outro analisador XSLT.
Outras dicas
http://pear.php.net/package/Ependocument pode ser o que você precisa. Eu mesmo não usei.
/*Name of the document file*/
$document = 'Template.odt';
/**Function to extract text*/
function extracttext($filename) {
$dataFile = "content.xml";
//Create a new ZIP archive object
$zip = new ZipArchive;
// Open the archive file
if (true === $zip->open($filename)) {
// If successful, search for the data file in the archive
if (($index = $zip->locateName($dataFile)) !== false) {
// Index found! Now read it to a string
$text = $zip->getFromIndex($index);
// Load XML from a string
// Ignore errors and warnings
$xml = new DOMDocument;
$xml->loadXML($text, LIBXML_NOENT | LIBXML_XINCLUDE | LIBXML_NOERROR | LIBXML_NOWARNING);
// Return XML
return $xml->saveXML();
}
//Close the archive file
$zip->close();
}
// In case of failure return a message
return "File no`enter code here`t found";
}
echo extracttext($document);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow