def parse_gpx(gpx_element, gpxns=None):
gpxns = gpxns if gpxns is not None else determine_gpx_namespace(gpx_element)<EOL>if gpx_element.tag != gpxns+'<STR_LIT>':<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>get_text = lambda tag: optional_text(gpx_element, gpxns+tag)<EOL>version = gpx_element.attrib['<STR_LIT:version>']<EOL>if not version.startswith('<STR_LIT:1.0>'):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>creator = gpx_element.attrib['<STR_LIT>']<EOL>name = get_text('<STR_LIT:name>')<EOL>description = get_text('<STR_LIT>')<EOL>author_name = get_text('<STR_LIT>')<EOL>email = get_text('<STR_LIT:email>')<EOL>author = Person(author_name, email)<EOL>url = get_text('<STR_LIT:url>')<EOL>urlname = get_text('<STR_LIT>')<EOL>links = make_links(url, urlname)<EOL>time = get_text('<STR_LIT:time>')<EOL>keywords = get_text('<STR_LIT>')<EOL>bounds_element = gpx_element.find(gpxns+'<STR_LIT>')<EOL>bounds = nullable(parse_bounds)(bounds_element)<EOL>metadata = Metadata(name=name, description=description, author=author,<EOL>links=links, time=time, keywords=keywords, bounds=bounds)<EOL>waypoint_elements = gpx_element.findall(gpxns+'<STR_LIT>')<EOL>waypoints = [parse_waypoint(waypoint_element, gpxns) for waypoint_element in waypoint_elements]<EOL>route_elements = gpx_element.findall(gpxns+'<STR_LIT>')<EOL>routes = [parse_route(route_element, gpxns) for route_element in route_elements]<EOL>track_elements = gpx_element.findall(gpxns+'<STR_LIT>')<EOL>tracks = [parse_track(track_element, gpxns) for track_element in track_elements]<EOL>gpx_model  = GpxModel(creator, metadata, waypoints, routes, tracks)<EOL>return gpx_model<EOL>
Parse a GPX file into a GpxModel.

    Args:
        xml: A file-like-object opened in binary mode - that is containing
             bytes rather than characters. The root element of the XML should
             be a <gpx> element containing a version attribute. GPX versions
             1.0 is supported.

    Returns:
        A GpxModel representing the data from the supplies xml.

    Raises:
        ValueError: The supplied XML could not be parsed as GPX.