Fix a problem of tag values which is not taken into account

(when equal to zero) when passing an array to XML object.
This commit is contained in:
Aymeric Derbois 2013-06-09 00:48:59 +02:00
parent e527eab5aa
commit 0cfdb87cdf
2 changed files with 14 additions and 1 deletions

View file

@ -375,6 +375,19 @@ XML;
$obj = Xml::fromArray($xml, 'attributes');
$xmlText = '<' . '?xml version="1.0" encoding="UTF-8"?><tags><tag id="1">defect</tag></tags>';
$this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML());
$xml = array(
'tag' => array(
'@' => 0,
'@test' => 'A test'
)
);
$obj = Xml::fromArray($xml);
$xmlText = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<tag test="A test">0</tag>
XML;
$this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML());
}
/**

View file

@ -310,7 +310,7 @@ class Xml {
}
$child = $dom->createElement($key);
if ($childValue) {
if (!is_null($childValue)) {
$child->appendChild($dom->createTextNode($childValue));
}
if ($childNS) {