Replies: 5   Views: 52
Handle other xml namespaces

Posted by Aldryss  · 18-03-2020 - 09:22


Our company uses phpdocx and we encountered a problem while importing a docx file where the document.xml has the following document declaration :

<w:document xmlns:w="" xmlns:aink="" xmlns:am3d="" xmlns:cx="" xmlns:cx1="" xmlns:cx2="" xmlns:cx3="" xmlns:cx4="" xmlns:cx5="" xmlns:cx6="" xmlns:cx7="" xmlns:cx8="" xmlns:m="" xmlns:mc="" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w14="" xmlns:w15="" xmlns:w16cid="" xmlns:w16se="" xmlns:wne="" xmlns:wp="" xmlns:wp14="" xmlns:wpi="" mc:Ignorable="w14 w15 w16se w16cid wne wp14" w:conformance="strict">

the error occurs when extracting text from a docx document (using the Docx2Text class), on 

$bodyNode = $this->domDocument->getElementsByTagNameNS('', 'body');

Could you handle other valid xml namespaces, so these documents are also parsed by phpdox?

Thanks a lot

Posted by admin  · 18-03-2020 - 09:32


What license and version of phpdocx are using?


Posted by Aldryss  · 18-03-2020 - 15:26

Hi, thanks for the quick reply, it's premium 9.5

Posted by admin  · 18-03-2020 - 16:11


The problem is that the DOCX uses the strict variant (w:conformance="strict"), that doesn't use the same XML namespaces than the transitional variant.

Strict variant support is a work in progress (its support is beta and it's being tested), and it will be included in the next release of phpdocx. You can use the transitional variant resaving the DOCX.


Posted by Aldryss  · 19-03-2020 - 17:23

Hi, do you have an ETA for this new release ?

Posted by admin  · 19-03-2020 - 17:28


The new class to work with strict variant DOCX is available to be used by all users with a Premium license and an active LUS.

If you have an active LUS, please send an e-mail to contact[at] with the username or e-mail of the user that purchased the license and if you are using the classic or namespaces package. The dev team will send you the new class and a sample to illustrate how to use it.