@classmethod<EOL><INDENT>def parse(cls, fptr, offset, length):<DEDENT>
num_bytes = offset + length - fptr.tell()<EOL>read_buffer = fptr.read(num_bytes)<EOL>if sys.hexversion < <NUM_LIT> and codecs.BOM_UTF8 in read_buffer:<EOL><INDENT>msg = ('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>msg = msg.format(offset=offset)<EOL>warnings.warn(msg, UserWarning)<EOL>read_buffer = read_buffer.replace(codecs.BOM_UTF8, b'<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>text = read_buffer.decode('<STR_LIT:utf-8>')<EOL><DEDENT>except UnicodeDecodeError as err:<EOL><INDENT>decl_start = read_buffer.find(b'<STR_LIT>')<EOL>if decl_start <= -<NUM_LIT:1>:<EOL><INDENT>msg = ('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>warnings.warn(msg.format(error=str(err)), UserWarning)<EOL>return XMLBox(xml=None, length=length, offset=offset)<EOL><DEDENT>text = read_buffer[decl_start:].decode('<STR_LIT:utf-8>')<EOL>msg = ('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>msg = msg.format(offset=offset, reason=err.reason)<EOL>warnings.warn(msg, UserWarning)<EOL><DEDENT>text = text.rstrip(chr(<NUM_LIT:0>))<EOL>bfptr = io.BytesIO(text.encode('<STR_LIT:utf-8>'))<EOL>try:<EOL><INDENT>xml = ET.parse(bfptr)<EOL><DEDENT>except ET.ParseError as err:<EOL><INDENT>msg = ('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>msg = msg.format(reason=str(err))<EOL>warnings.warn(msg, UserWarning)<EOL>xml = None<EOL><DEDENT>return cls(xml=xml, length=length, offset=offset)<EOL>
Parse XML box.

        Parameters
        ----------
        fptr : file
            Open file object.
        offset : int
            Start position of box in bytes.
        length : int
            Length of the box in bytes.

        Returns
        -------
        XMLBox
            Instance of the current XML box.