Initialize an instance of :class:`lxml.etree.XMLParser` with appropriate
    settings for validation.  If validation is requested and the specified
    instance of :class:`XmlObject` has an XSD_SCHEMA defined, that will be used.
    Otherwise, uses DTD validation. Switched resolver to None to skip validation.

def _get_xmlparser(xmlclass=XmlObject, validate=False, resolver=None):
    """Initialize an instance of :class:`lxml.etree.XMLParser` with appropriate
    settings for validation.  If validation is requested and the specified
    instance of :class:`XmlObject` has an XSD_SCHEMA defined, that will be used.
    Otherwise, uses DTD validation. Switched resolver to None to skip validation.
    """
    if validate:
        if hasattr(xmlclass, 'XSD_SCHEMA') and xmlclass.XSD_SCHEMA is not None:
            # If the schema has already been loaded, use that.
            # (since we accessing the *class*, accessing 'xmlschema' returns a property,
            # not the initialized schema object we actually want).
            xmlschema = getattr(xmlclass, '_xmlschema', None)
            # otherwise, load the schema
            if xmlschema is None:
                xmlschema = loadSchema(xmlclass.XSD_SCHEMA)
            opts = {'schema': xmlschema}
        else:
            # if configured XmlObject does not have a schema defined, assume DTD validation
            opts = {'dtd_validation': True}
    else:
        # If validation is not requested, then the parsing should fail
        # only for well-formedness issues.
        #
        # Therefore, we must turn off collect_ids, otherwise lxml will
        # have a problem with duplicate IDs as it collects
        # them. However, the XML spec declares ID uniqueness as a
        # validation constraint, not a well-formedness
        # constraint. (See https://www.w3.org/TR/xml/#id.)
        opts = {"collect_ids": False}

    parser = etree.XMLParser(**opts)

    if resolver is not None:
        parser.resolvers.add(resolver)

    return parser