note 105013 deleted from simplexmlelement.attributes by danbrown
| From: | danbrown@php.net | Date: | Mon, 25 Jul 2011 12:31:22 +0000 |
| Subject: | note 105013 deleted from simplexmlelement.attributes by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-181841@lists.php.net to get a copy of this message | ||
Note Submitter: jay_milagrosoATyahooDOTcom
----
$array = array();
$xmlObject = new SimpleXMLElement($data);
foreach ($xmlObject->children() as $child) {
foreach($child->children() as $child1) {
if($child1->attributes()) {
$attribute = $child1->attributes();
foreach($attribute as $a => $b) {
$array[$child->getName()][] = array((string)$child1->getName() =>
(string)$child1, (string)$a => (string)$b);
}
} else {
$array[$child->getName()][] = array((string)$child1->getName() =>
(string)$child1);
}
}
}
Used php 5.3.1
Happy coding!