Answer the question
In order to leave comments, you need to log in
How to convert word to xml format using php?
it is necessary to enter the contents of a word document containing text, pictures into mysql tables. Estimated file structure
question text picture text
answer A) text
B) text
C) text
D) text
E) text
correct answer B
To do this, I want to convert to xml and manually import into MySQL
<database name="DB_NAME">
<!-- Таблица questions -->
<table name="questions">
<column name="question_id">1</column>
<column name="question">question 1</column>
<column name="answer_a">answer_a 1</column>
<column name="answer_b">answer_b 2</column>
<column name="answer_c">answer_c 3</column>
<column name="answer_d">answer_d 4</column>
<column name="answer_e">answer_e 5</column>
<column name="right_answer">right_answer 1</column>
</table>
Answer the question
In order to leave comments, you need to log in
In theory, a docx format document is already an xml document, only compressed by the zip algorithm. All you need is:
$zip = new ZipArchive;
$doc_file = './publisher.docx';
$zip->open($doc_file);
$zip->extractTo('./tmp');
$xml = simplexml_load_file("./tmp/path_to.xml");
$xml->registerXPathNamespace('w',"http://schemas.openxmlformats.org/wordprocessingml/2006/main");
$text = $xml->xpath('//w:t');
echo '<pre>'; print_r($text); echo '</pre>';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question