/** * recursive function for xml output * @return string */ function writeTag($xmlNode, $depth) { $tabs = ''; if ($depth) { $tabs = str_repeat("\t", $depth); } $out = $tabs; $childs = count($xmlNode['children']); // open tag $out .= fuXml::openTag($xmlNode['name'], $xmlNode['attributes'], 'oneliner' == $xmlNode['type'], $childs); // content if ('oneliner' != $xmlNode['type'] && $xmlNode['content']) { $out .= $xmlNode['content']; if ($childs) { $out .= "\n"; } } // childs if ($childs) { for ($i = 0; isset($xmlNode['children'][$i]); $i++) { $out .= fuXml::writeTag($xmlNode['children'][$i], $depth + 1); } } // close if ('oneliner' != $xmlNode['type']) { if ($childs) { $out .= "{$tabs}"; } $out .= '</' . $xmlNode['name'] . ">\n"; } return $out; }