Cookbook
- Learn phpdocx in 5 minutes
- Tutorial
- API quick guide
- HTML to Word
- HTML Extended
- Conversion plugin
- Word to HTML
- DOCXPath
- Bulk processing
- DOCXCustomizer
- Digital signature
- Cryptophpdocx
- Right to left languages
- phpdocx CLI command
- Tracking
- Artificial Intelligence
- Blockchain for documents
- JavaScript API
- Compiled mode
Parse huge DOCX contents
PHP has default size and depth limits to parse XML files with DOMDocument, simplexml_load_string and other XML features. To avoid this limitation, the LIBXML_PARSEHUGE predefined constant sets XML_PARSE_HUGE flag, which relaxes any hardcoded limit from the parser.
From small to very large XML contents can be parsed correctly without using this flag, but it's required to parse huge XML contents.
This flag is not enabled by default in PHP to avoid DDOS and integer overflow attacks when reading huge XML files.
Although in most cases it's not necessary to read and parse DOCX files with phpdocx, if needed, LIBXML_PARSEHUGE can be enabled to parse huge XML files by calling the enableHugeXmlMode static function included in the XmlUtilities class:
Extra XML predefined constants can also be added with the $xmlFlags static variable: