Cookbook

Parse huge XLSX 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 XLSX files with phpxlsx, 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: