note 56100 deleted from function.xml-parse-into-struct by cmb
| From: | cmb@php.net | Date: | Sun, 21 Oct 2018 09:14:13 +0000 |
| Subject: | note 56100 deleted from function.xml-parse-into-struct by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-209474@lists.php.net to get a copy of this message | ||
Note Submitter: info at gramba dot tv
----
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;
}
?>