note 56100 added to function.xml-parse-into-struct

From: Date: Tue, 23 Aug 2005 15:54:38 +0000
Subject: note 56100 added to function.xml-parse-into-struct
Groups: php.notes 
Request: Send a blank email to php-notes+get-94081@lists.php.net to get a copy of this message
I was working with the xml2array functions below and had big performance problems. I fired them on a 20MB XML file and had to quit since all approaches of parsing where just too slow (more than 20 Minute parsing etc..). The solution was parsing it manually with preg_match, which increased performance by more than 20 times (processing time about 1 minute). Rough example function with high performance: <?php function customXMLtoARRAY($xmlstring) { // get all nodes preg_match_all("#<node>(.*?)</node>#s",$xmlstring,$nodes); $xmlstring = NULL; $allnodes = array(); // put subnodes into node while($nodes = array_pop($nodes[1])) { $nodecontent = array(); // Content1 preg_match("#<content1>(.*?)</content1>#",$eventreihe,$val); $nodecontent['content1'] = $val[1]; $allnodes[] = $nodecontent; } return $allnodes; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.xml-parse-into-struct.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56100 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56100&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56100&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56100&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56100&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56100&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56100&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56100&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#94081) next »