diff --git a/lib/Cake/Test/Case/Utility/XmlTest.php b/lib/Cake/Test/Case/Utility/XmlTest.php
index 46dac3b27..7896ed4c9 100644
--- a/lib/Cake/Test/Case/Utility/XmlTest.php
+++ b/lib/Cake/Test/Case/Utility/XmlTest.php
@@ -375,6 +375,19 @@ XML;
$obj = Xml::fromArray($xml, 'attributes');
$xmlText = '<' . '?xml version="1.0" encoding="UTF-8"?>defect';
$this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML());
+
+ $xml = array(
+ 'tag' => array(
+ '@' => 0,
+ '@test' => 'A test'
+ )
+ );
+ $obj = Xml::fromArray($xml);
+ $xmlText = <<
+0
+XML;
+ $this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML());
}
/**
diff --git a/lib/Cake/Utility/Xml.php b/lib/Cake/Utility/Xml.php
index 862f6c1d4..88d4e19a0 100644
--- a/lib/Cake/Utility/Xml.php
+++ b/lib/Cake/Utility/Xml.php
@@ -310,7 +310,7 @@ class Xml {
}
$child = $dom->createElement($key);
- if ($childValue) {
+ if (!is_null($childValue)) {
$child->appendChild($dom->createTextNode($childValue));
}
if ($childNS) {