diff --git a/lib/Cake/Test/Case/Utility/XmlTest.php b/lib/Cake/Test/Case/Utility/XmlTest.php index 9849984ac75..b28a4efc042 100644 --- a/lib/Cake/Test/Case/Utility/XmlTest.php +++ b/lib/Cake/Test/Case/Utility/XmlTest.php @@ -644,6 +644,16 @@ public function testToArray() { ) ); $this->assertEquals($expected, Xml::toArray($obj)); + + $xml = '0'; + $obj = Xml::build($xml); + $expected = array( + 'tag' => array( + '@type' => 'myType', + '@' => 0 + ) + ); + $this->assertEquals($expected, Xml::toArray($obj)); } /** diff --git a/lib/Cake/Utility/Xml.php b/lib/Cake/Utility/Xml.php index 9fd60957893..f446798a301 100644 --- a/lib/Cake/Utility/Xml.php +++ b/lib/Cake/Utility/Xml.php @@ -360,7 +360,7 @@ protected static function _toArray($xml, &$parentData, $ns, $namespaces) { $asString = trim((string)$xml); if (empty($data)) { $data = $asString; - } elseif (!empty($asString)) { + } elseif (strlen($asString) > 0) { $data['@'] = $asString; }