Moved the XML parsing logic in to a separate factory

See #9