add-domain: Refactor domain XML parsing code.

This is just code motion.