def parse(self, xml_root, on_error=None):
        '''
        Parse all <path> elements from xml_root.

        Optional on_error arg specifies a callback function to be run when
        an error occurs during parsing.
        The specified on_error function must accept 3 arguments:
            <svg filename>, <path_tag>, <error message>
        An example on_error handler is provided as svg_load.svg_parser.parse_warning(),
        where all SvgParseErrors are converted to warning messages.  See usage below:
        >>> import re
        >>> svg_parser = SvgParser()
        >>> path_tag = etree.XML("""
        ...     <path
        ...     xmlns="http://www.w3.org/2000/svg"
        ...     xmlns:dc="http://purl.org/dc/elements/1.1/"
        ...     xmlns:cc="http://creativecommons.org/ns#"
        ...     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        ...     xmlns:svg="http://www.w3.org/2000/svg"
        ...     xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
        ...     xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
        ...     id="path13231"
        ...     d="M8 4 l-4,4"
        ...     linecap="square"
        ...     stroke="#000000"
        ...     stroke-width="0.25"
        ...     />""")
        >>> with warnings.catch_warnings(record=True) as w:
        ...     svg = svg_parser.parse(path_tag, on_error=parse_warning)
        >>> print w[-1].category
        <type 'exceptions.RuntimeWarning'>
        >>> match = re.search(r'^Error parsing None:\d+, unsupported svg path command: l', str(w[-1].message))
        >>> print match is None
        False
        >>> path_tag = etree.XML("""
        ...     <path
        ...     xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
        ...     xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#"
        ...     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        ...     xmlns:svg="http://www.w3.org/2000/svg"
        ...     xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
        ...     style="fill:#0000ff;stroke:#ff0000;stroke-width:0.10000000000000001;stroke-miterlimit:4;stroke-dasharray:none"
        ...     id="path18327"
        ...     d="M 636.0331,256.9345 L 636.0331,256.9345"
        ...     inkscape:connector-curvature="0"/>""")
        >>> with warnings.catch_warnings(record=True) as w:
        ...     svg = svg_parser.parse(path_tag, on_error=parse_warning)
        >>> print w[-1].category
        <type 'exceptions.RuntimeWarning'>
        >>> match = re.search(r'^Error parsing None:\d+, loop needs 3 or more verts', str(w[-1].message))
        >>> print match is None
        False
        '''
        svg = Svg()
        svg_namespace = {'svg': 'http://www.w3.org/2000/svg'}
        path_tags = xml_root.xpath('(/svg:svg|/svg:svg/svg:g)/svg:path',
                                   namespaces=svg_namespace)
        parser = PathParser()
        for path_tag in path_tags:
            try:
                id, svg_path = parser.parse(path_tag)
                if svg_path.loops:
                    svg.add_path(id, svg_path)
            except (ParseError, ) as why:
                filename = getattr(self, 'filename', None)
                args = (filename, path_tag, why.message)
                if on_error:
                    on_error(*args)
                else:
                    raise SvgParseError(*args)

        if svg.paths:
            x, y = svg.get_boundary().get_center()
            for svg_path in svg.paths.values():
                svg_path.offset(-x, -y)
        return svg
Parse all <path> elements from xml_root.

        Optional on_error arg specifies a callback function to be run when
        an error occurs during parsing.
        The specified on_error function must accept 3 arguments:
            <svg filename>, <path_tag>, <error message>
        An example on_error handler is provided as svg_load.svg_parser.parse_warning(),
        where all SvgParseErrors are converted to warning messages.  See usage below:
        >>> import re
        >>> svg_parser = SvgParser()
        >>> path_tag = etree.XML("""
        ...     <path
        ...     xmlns="http://www.w3.org/2000/svg"
        ...     xmlns:dc="http://purl.org/dc/elements/1.1/"
        ...     xmlns:cc="http://creativecommons.org/ns#"
        ...     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        ...     xmlns:svg="http://www.w3.org/2000/svg"
        ...     xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
        ...     xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
        ...     id="path13231"
        ...     d="M8 4 l-4,4"
        ...     linecap="square"
        ...     stroke="#000000"
        ...     stroke-width="0.25"
        ...     />""")
        >>> with warnings.catch_warnings(record=True) as w:
        ...     svg = svg_parser.parse(path_tag, on_error=parse_warning)
        >>> print w[-1].category
        <type 'exceptions.RuntimeWarning'>
        >>> match = re.search(r'^Error parsing None:\d+, unsupported svg path command: l', str(w[-1].message))
        >>> print match is None
        False
        >>> path_tag = etree.XML("""
        ...     <path
        ...     xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
        ...     xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#"
        ...     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        ...     xmlns:svg="http://www.w3.org/2000/svg"
        ...     xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
        ...     style="fill:#0000ff;stroke:#ff0000;stroke-width:0.10000000000000001;stroke-miterlimit:4;stroke-dasharray:none"
        ...     id="path18327"
        ...     d="M 636.0331,256.9345 L 636.0331,256.9345"
        ...     inkscape:connector-curvature="0"/>""")
        >>> with warnings.catch_warnings(record=True) as w:
        ...     svg = svg_parser.parse(path_tag, on_error=parse_warning)
        >>> print w[-1].category
        <type 'exceptions.RuntimeWarning'>
        >>> match = re.search(r'^Error parsing None:\d+, loop needs 3 or more verts', str(w[-1].message))
        >>> print match is None
        False