<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse(self, xml_file, view_name=None) -> XmlNode: """Parses xml file with xml_path and returns XmlNode"""

        self._setup_parser()
        try:
            self._view_name = view_name
            self._parser.ParseFile(xml_file)
        except ExpatError as error:
            # pylint: disable=E1101
            raise XmlError(errors.messages[error.code], ViewInfo(view_name, error.lineno))

        root = self._root
        self._reset()
        return root