I parsed the XML file from DOCX (ZIP archive) to array by xml_parse_into_struct
. Here is the result.
Array
(
[0] => Array
(
[tag] => W:DOCUMENT
[type] => open
[level] => 1
[attributes] => Array
(
[XMLNS:WPC] => http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas
)
)
[1] => Array
(
[tag] => W:BODY
[type] => open
[level] => 2
)
[2] => Array
(
[tag] => W:P
[type] => open
[level] => 3
[attributes] => Array
(
[W:RSIDR] => 00383EED
[W:RSIDRDEFAULT] => 00383EED
[W:RSIDP] => 001F2B24
)
)
...
[15] => Array
(
[tag] => W:P
[type] => close
[level] => 3
)
...
[2348] => Array
(
[tag] => W:BODY
[type] => close
[level] => 2
)
[2349] => Array
(
[tag] => W:DOCUMENT
[type] => close
[level] => 1
)
)
After some changes I need to convert it back to XML file first (and then to a DOCX file). Here is the structure of XML file I need:
<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas">
<w:body>
<w:p w:rsidR="00383EED" w:rsidRDefault="00383EED" w:rsidP="001F2B24">...</w:p>
...
</w:body>
</w:document>
How can I do this?