I wrote something that did things to huge XML files (2meg+) and it took a
long time! (around 10 mins)
I used this code to read and process the XML into a arrays
function GetChildren($vals, &$i) {
$children = array();
if ($vals[$i]['value'])
array_push($children, $vals[$i]['value']);
while (++$i < count($vals)) {
switch ($vals[$i]['type']) {
case 'cdata':
array_push($children, $vals[$i]['value']);
break;
case 'complete':
$children[$vals[$i]['tag']] = $vals[$i]['value'];
break;
case 'open':
$children[] = GetChildren($vals,$i);
break;
case 'close':
return $children;
break;
}
}
}
function GetXMLTree($XML) {
$p = xml_parser_create("UTF-8");
xml_parser_set_option($p, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($p, $XML, $vals, $index) OR DIE("Invalid XML
file!");
xml_parser_free($p);
$i = 0;
return GetChildren($vals, $i);
}
Hope that helps :P
"Blake Barnett" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> What is the recommended XML parser for use with PHP 4.2.1? (and also
> 4.1.0 if anyone is willing to answer that as well?)
>
> From reading the list archives I'm seeing a lot of people bash expat and
> lean toward libxml2, I just wanted to get the consensus before I commit
> a project to using one or the other.
>
> Thanks,
>
> --
> Blake Barnett (bdb) <[EMAIL PROTECTED]>
> Sr. Unix Administrator
> DevelopOnline.com office: 480-377-6816
>
> Learning is a skill, you get better at it with practice.
>
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php