@ilwdchar_compat<EOL>def open_xmldoc(fobj, **kwargs):
from ligo.lw.ligolw import (Document, LIGOLWContentHandler)<EOL>from ligo.lw.lsctables import use_in<EOL>from ligo.lw.utils import (load_filename, load_fileobj)<EOL>use_in(kwargs.setdefault('<STR_LIT>', LIGOLWContentHandler))<EOL>try:  <EOL><INDENT>if isinstance(fobj, string_types):<EOL><INDENT>return load_filename(fobj, **kwargs)<EOL><DEDENT>if isinstance(fobj, FILE_LIKE):<EOL><INDENT>return load_fileobj(fobj, **kwargs)[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>except (OSError, IOError):  <EOL><INDENT>return Document()<EOL><DEDENT>except LigolwElementError as exc:<EOL><INDENT>if LIGO_LW_COMPAT_ERROR.search(str(exc)):<EOL><INDENT>try:<EOL><INDENT>return open_xmldoc(fobj, ilwdchar_compat=True, **kwargs)<EOL><DEDENT>except Exception:  <EOL><INDENT>pass<EOL><DEDENT><DEDENT>raise<EOL><DEDENT>
Try and open an existing LIGO_LW-format file, or create a new Document

    Parameters
    ----------
    fobj : `str`, `file`
        file path or open file object to read

    **kwargs
        other keyword arguments to pass to
        :func:`~ligo.lw.utils.load_filename`, or
        :func:`~ligo.lw.utils.load_fileobj` as appropriate

    Returns
    --------
    xmldoc : :class:`~ligo.lw.ligolw.Document`
        either the `Document` as parsed from an existing file, or a new, empty
        `Document`