diff --git a/cake/libs/xml.php b/cake/libs/xml.php index ba37d5d96..4c2e03894 100644 --- a/cake/libs/xml.php +++ b/cake/libs/xml.php @@ -664,6 +664,7 @@ class XmlNode extends Object { foreach ($this->children as $child) { $key = $camelize ? Inflector::camelize($child->name) : $child->name; + //debug($key); if (is_a($child, 'XmlTextNode')) { $out['value'] = $child->value; @@ -688,7 +689,7 @@ class XmlNode extends Object { if (isset($out[$key]) || isset($multi[$key])) { if (!isset($multi[$key])) { $multi[$key] = array($out[$key]); - unset($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 bb71e1456..abcb7d0f4 100644 --- a/cake/tests/cases/libs/xml.test.php +++ b/cake/tests/cases/libs/xml.test.php @@ -1244,6 +1244,43 @@ class XmlTest extends CakeTestCase { ) ); $this->assertEqual($result, $expected); + + $text = '
'; + $xml = new Xml($text); + $result = $xml->toArray(); + $expected = array( + 'Main' => array( + 'First' => array( + array('label' => 'first type node 1'), + array('label' => 'first type node 2') + ), + 'Second' => array('label'=>'second type node') + ) + ); + $this->assertIdentical($result,$expected); + + $text = '
'; + $xml = new Xml($text); + $result = $xml->toArray(); + $expected = array( + 'Main' => array( + 'First' => array( + array('label' => 'first type node 1'), + array('label' => 'first type node 2') + ), + 'Second' => array('label'=>'second type node'), + 'Collection' => array( + 'Fifth' => array('label' => 'fifth type node'), + 'Third' => array( + array('label' => 'third type node 1'), + array('label' => 'third type node 2'), + array('label' => 'third type node 3'), + ), + 'Fourth' => array('label' => 'fourth type node'), + ) + ) + ); + $this->assertIdentical($result,$expected); } /** * testAppend method