note 11233 added to xml_parse_into_struct
| From: | nyk at cowham dot net | Date: | Sun, 11 Feb 2001 23:56:57 +0000 |
| Subject: | note 11233 added to xml_parse_into_struct | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-10915@lists.php.net to get a copy of this message | ||
The code submitted by gdemartini@bol.com.br is generally quite useful. However, it only creates a
tree from elements and attributes and not the cdata enclosed by elements. Any cdata is lost. If you
want to capture cdata then you need to modify the switch statement for case 'complete'
thus:
...
case 'complete':
array_push($children, array('tag' => $vals[$i]['tag'],
'attributes' => $vals[$i]['attributes'], 'value' =>
$vals[$i]['value']));
break;
...
Adding the map, 'value' => $vals[$i]['value'] to the array will make the
original code more complete.
http://www.php.net/manual/en/function.xml-parse-into-struct.php