Skip to content

Commit

Permalink
#89 - Remove empty xml child nodes for empty parameters ending with a…
Browse files Browse the repository at this point in the history
…n s.
  • Loading branch information
tyzoid committed Jul 22, 2017
1 parent 15689dc commit 407933b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion source/Jacwright/RestServer/RestServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,8 @@ private function xml_encode($mixed, $domElement = null, $DOMDocument = null) {
$DOMDocument->formatOutput = true;
$this->xml_encode($mixed, $DOMDocument, $DOMDocument);
echo $DOMDocument->saveXML();
} else if (empty($mixed)) {
$domElement->appendChild($DOMDocument->createTextNode(null));
} else if (is_array($mixed)) {
foreach ($mixed as $index => $mixedElement) {
if (is_int($index)) {
Expand All @@ -501,7 +503,7 @@ private function xml_encode($mixed, $domElement = null, $DOMDocument = null) {
$domElement->appendChild($plural);
$node = $plural;

if (!(rtrim($index, 's') === $index)) {
if (!(rtrim($index, 's') === $index) && !empty($mixedElement)) {
$singular = $DOMDocument->createElement(rtrim($index, 's'));
$plural->appendChild($singular);
$node = $singular;
Expand Down

0 comments on commit 407933b

Please sign in to comment.