Sorry for any inconvenience ...
The appendChild-method of phpDOM uses and relies on the new_child-method of the DOM/XML Library (--with-dom)
Any newline character or tabulator character would be treated as a text node in the dom-tree. The problem is, that there is currently no method to create XML_TEXT_NODEs other than as the content of an XML_ELEMENT_NODE.
Newly created nodes therefore appear on one single line. But why worrying, the meaning of the created document is the same.
Regards
Dietmar