def features_from_xml(
    filepath: str | Path,
    *,
    polygon: Polygon | MultiPolygon | None = None,
    tags: dict[str, bool | str | list[str]] | None = None,
    encoding: str = "utf-8",
) -> gpd.GeoDataFrame:
    """
    Create a GeoDataFrame of OSM features from data in an OSM XML file.

    Because this function creates a GeoDataFrame of features from an OSM XML
    file that has already been downloaded (i.e., no query is made to the
    Overpass API), the `polygon` and `tags` arguments are optional. If they
    are None, filtering will be skipped.

    Parameters
    ----------
    filepath
        Path to file containing OSM XML data.
    polygon
        Spatial boundaries to optionally filter the final GeoDataFrame.
    tags
        Query tags to optionally filter the final GeoDataFrame.
    encoding
        The OSM XML file's character encoding.

    Returns
    -------
    gdf
        The features, multi-indexed by element type and OSM ID.
    """
    # if tags or polygon is None, create an empty object to skip filtering
    if tags is None:
        tags = {}
    if polygon is None:
        polygon = Polygon()

    # transmogrify OSM XML file to JSON then create GeoDataFrame from it
    response_jsons = [_osm_xml._overpass_json_from_xml(Path(filepath), encoding)]
    gdf = _create_gdf(response_jsons, polygon, tags)

    # drop misc element attrs that might have been added from OSM XML file
    to_drop = set(gdf.columns) & {"changeset", "timestamp", "uid", "user", "version"}
    return gdf.drop(columns=list(to_drop))

    Create a GeoDataFrame of OSM features from data in an OSM XML file.

    Because this function creates a GeoDataFrame of features from an OSM XML
    file that has already been downloaded (i.e., no query is made to the
    Overpass API), the `polygon` and `tags` arguments are optional. If they
    are None, filtering will be skipped.

    Parameters
    ----------
    filepath
        Path to file containing OSM XML data.
    polygon
        Spatial boundaries to optionally filter the final GeoDataFrame.
    tags
        Query tags to optionally filter the final GeoDataFrame.
    encoding
        The OSM XML file's character encoding.

    Returns
    -------
    gdf
        The features, multi-indexed by element type and OSM ID.
    
osmnx/features.py