[TASK] Improve XML structure building using DomDocument