private function buildNodeTree(SdlTag $node) { $tag = strtolower($node->getName()); $attr = ""; foreach ($node->getAttributes() as $name => $value) { $attr .= " {$name}=\"{$value}\""; } $out = ""; if ($node->hasChildren()) { if ($tag) { $out .= "<{$tag}{$attr}>"; } foreach ($node->getChildren() as $child) { $out .= $this->buildNodeTree($child); } if ($tag) { $out .= "</{$tag}>"; } } else { if (count($node) > 0) { if (!$tag) { $out .= $node[0]; } else { $out .= "<{$tag}{$attr}>" . $node[0] . "</{$tag}>"; } } else { $out .= "<{$tag}{$attr}>"; } } return $out; }