[CLEANUP] Move the creation of the DOMDocument to a separate method.