<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def from_xml(xml_path, mapsource_prefix=""):
 """ Create a MapSource object from a MOBAC mapsource xml. Args: xml_path: path to the MOBAC mapsource xml file. mapsource_prefix: root path of the mapsource folder. Used to determine relative path within the maps directory. Note: The Meta-Information is read from the xml <id>, <folder>, <name> tags. If <id> is not available it defaults to the xml file basename. If <folder> is not available if defaults to the folder of the xml file with the `mapsource_prefix` removed. The function first tries <url>, <minZoom>, <maxZoom> from <customMapSource> tags within the <layers> tag. If the <layers> tag is not available, the function tries to find <url>, <minZoom> and <maxZoom> on the top level. If none of thie information is found, a MapSourceException is raised. Returns: MapSource: Raises: MapSourceException: when the xml file could not be parsed properly. """

        xmldoc = xml.etree.ElementTree.parse(xml_path).getroot()

        map_id = os.path.splitext(os.path.basename(xml_path))[0]
        map_name = map_id
        map_folder = re.sub("^" + re.escape(mapsource_prefix), "", os.path.dirname(xml_path))
        bbox = None
        layers = None

        for elem in xmldoc.getchildren():
            if elem.tag == 'id':
                map_id = elem.text
            elif elem.tag == 'name':
                map_name = elem.text
            elif elem.tag == 'folder':
                map_folder = elem.text
            elif elem.tag == 'region':
                bbox = MapSource.parse_xml_boundary(elem)
            elif elem.tag == 'layers':
                layers = MapSource.parse_xml_layers(elem)

        if map_folder is None:
            map_folder = "" # fallback if bad specification in xml
        if layers is None:  # layers tag not found, expect url etc. in main xmldoc
            layers = [MapSource.parse_xml_layer(xmldoc)]

        ms = MapSource(map_id, map_name, map_folder, bbox=bbox)
        ms.layers = layers
        return ms