note 69442 added to function.xml-parse-into-struct
| From: | mad dot cat at mcmadcat dot com | Date: | Wed, 06 Sep 2006 11:55:29 +0000 |
| Subject: | note 69442 added to function.xml-parse-into-struct | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-116754@lists.php.net to get a copy of this message | ||
this my love function:
<?php
function mc_parse_xml($filename)
{
$xml = file_get_contents($filename);
$p = xml_parser_create();
xml_parse_into_struct($p, $xml, $values, $index);
xml_parser_free($p);
for ($i=0;$i<count($values);$i++) {
if (isset($values[$i]['attributes'])) {
$parent = $values[$i]['tag'];
$keys = array_keys($values[$i]['attributes']);
for ($z=0;$z<count($keys);$z++)
{
$content[$parent][$i][$keys[$z]] = $values[$i]['attributes'][$keys[$z]];
if (isset($content[$parent][$i]['VALUE']))
$content[$parent][$i]['VALUE'] = $values[$i]['value'];
}
}
}
foreach ($content as $key => $values) {
$content[$key] = array_values($content[$key]);
}
if (is_array($content)) return $content;
else return false;
}
?>
----
Server IP: 195.222.164.18
Probable Submitter: 84.17.229.62
----
Manual Page -- http://www.php.net/manual/en/function.xml-parse-into-struct.php
Edit -- https://master.php.net/note/edit/69442
Del: integrated -- https://master.php.net/note/delete/69442/integrated
Del: useless -- https://master.php.net/note/delete/69442/useless
Del: bad code -- https://master.php.net/note/delete/69442/bad+code
Del: spam -- https://master.php.net/note/delete/69442/spam
Del: non-english -- https://master.php.net/note/delete/69442/non-english
Del: in docs -- https://master.php.net/note/delete/69442/in+docs
Del: other reasons-- https://master.php.net/note/delete/69442
Reject -- https://master.php.net/note/reject/69442
Search -- https://master.php.net/manage/user-notes.php