diff --git a/cake/libs/xml.php b/cake/libs/xml.php index 437719a59..691cd5dba 100644 --- a/cake/libs/xml.php +++ b/cake/libs/xml.php @@ -672,7 +672,6 @@ class XmlNode extends Object { continue; } elseif (isset($child->children[0]) && is_a($child->children[0], 'XmlTextNode')) { $value = $child->children[0]->value; - if ($child->attributes) { $value = array_merge(array('value' => $value), $child->attributes); } @@ -688,10 +687,10 @@ class XmlNode extends Object { continue; } elseif (count($child->children) === 0 && $child->value == '') { $value = $child->attributes; - if (isset($out[$child->name]) || isset($multi[$key])) { + if (isset($out[$key]) || isset($multi[$key])) { if (!isset($multi[$key])) { - $multi[$key] = array($out[$child->name]); - unset($out[$child->name]); + $multi[$key] = array($out[$key]); + unset($out[$key]); } $multi[$key][] = $value; } elseif (!empty($value)) { diff --git a/cake/tests/cases/libs/xml.test.php b/cake/tests/cases/libs/xml.test.php index 793c573eb..82c5b5c17 100644 --- a/cake/tests/cases/libs/xml.test.php +++ b/cake/tests/cases/libs/xml.test.php @@ -1188,7 +1188,29 @@ class XmlTest extends CakeTestCase { ) ) )); + $this->assertEqual($result, $expected); + $text = ' + + + + + + + '; + $xml = new Xml($text); + $result = $xml->toArray(); + $expected = array( + 'Root' => array( + 'Child' => array( + array('id' => 1, 'other' => 1), + array('id' => 2, 'other' => 1), + array('id' => 3, 'other' => 1), + array('id' => 4, 'other' => 1), + array('id' => 5, 'other' => 1) + ) + ) + ); $this->assertEqual($result, $expected); } /**