I\'m blind, I can\'t see the error, where is it?
The script enters all IFs at least 1 time.
Before:
$xml = new DOMDocument(\'1.0\', \'utf-8\');