From 613506331b35b485b2bfd2117f339e74e562acda Mon Sep 17 00:00:00 2001 From: Tim Grocki Date: Fri, 8 Nov 2019 21:14:37 +0100 Subject: [PATCH] added support for large files and added more detailed error info --- convert.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/convert.php b/convert.php index 18198a8..85193a8 100755 --- a/convert.php +++ b/convert.php @@ -45,10 +45,16 @@ // Load XML file $file = file_get_contents($arguments['filename']); +libxml_use_internal_errors(true); + $xml = str_replace('xmlns=', 'ns=', $file); //$string is a string that contains xml... -$xml = new SimpleXMLElement($xml); +//$xml = new SimpleXMLElement($xml); +try { $xml = new SimpleXMLElement($xml, LIBXML_COMPACT | LIBXML_PARSEHUGE); } catch (Exception $e) { echo $e; } +foreach(libxml_get_errors() as $error) { + echo "\t", $error->message; +} $result = $xml->xpath('page'); $count = 0;