Added xml_document overload for parse thread.
Refactored common code.
Refactored repeated code.