from typing import Optional
import re


def get_package_version(
    package_xml_path: str,
) -> Optional[str]:
    """
    Get a package's version from its package.xml file.

    :param package_xml_path: the path to the package's package.xml file
    :return: the version, or None if it failed
    """
    version = None
    with open(package_xml_path, 'r') as package_xml_file:
        content = package_xml_file.read()
        version_match = re.match(r'.*<version>(.*)<\/version>.*', content, flags=re.DOTALL)
        if version_match:
            version = version_match.group(1)
    return version