mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
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:
parent
e527eab5aa
commit
0cfdb87cdf
2 changed files with 14 additions and 1 deletions
|
@ -375,6 +375,19 @@ XML;
|
||||||
$obj = Xml::fromArray($xml, 'attributes');
|
$obj = Xml::fromArray($xml, 'attributes');
|
||||||
$xmlText = '<' . '?xml version="1.0" encoding="UTF-8"?><tags><tag id="1">defect</tag></tags>';
|
$xmlText = '<' . '?xml version="1.0" encoding="UTF-8"?><tags><tag id="1">defect</tag></tags>';
|
||||||
$this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML());
|
$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());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -310,7 +310,7 @@ class Xml {
|
||||||
}
|
}
|
||||||
|
|
||||||
$child = $dom->createElement($key);
|
$child = $dom->createElement($key);
|
||||||
if ($childValue) {
|
if (!is_null($childValue)) {
|
||||||
$child->appendChild($dom->createTextNode($childValue));
|
$child->appendChild($dom->createTextNode($childValue));
|
||||||
}
|
}
|
||||||
if ($childNS) {
|
if ($childNS) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue