<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_xml_to_obj(self, xml_file, check_version=True, check_root=True, encoding=None):
 """Creates a STIX binding object from the supplied xml file. Args: xml_file: A filename/path or a file-like object representing a STIX instance document check_version: Inspect the version before parsing. check_root: Inspect the root element before parsing. encoding: The character encoding of the input `xml_file`. Raises: .UnknownVersionError: If `check_version` is ``True`` and `xml_file` does not contain STIX version information. .UnsupportedVersionError: If `check_version` is ``False`` and `xml_file` contains an unsupported STIX version. .UnsupportedRootElement: If `check_root` is ``True`` and `xml_file` contains an invalid root element. """

        root = get_etree_root(xml_file, encoding=encoding)

        if check_root:
            self._check_root_tag(root)

        if check_version:
            self._check_version(root)

        entity_class = self.get_entity_class(root.tag)
        entity_obj = entity_class._binding_class.factory()
        entity_obj.build(root)

        return entity_obj