import re
import xml.etree.ElementTree as ET
content = """<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>AutoMapper</id>
<version>9.0.0</version>
<authors>Jimmy Bogard</authors>
<owners>Jimmy Bogard</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<licenseUrl>https://g...content-available-to-author-only...b.com/AutoMapper/AutoMapper/blob/master/LICENSE.txt</licenseUrl>
<projectUrl>https://a...content-available-to-author-only...r.org/</projectUrl>
<iconUrl>https://s...content-available-to-author-only...s.com/automapper/icon.png</iconUrl>
<description>A convention-based object-object mapper.</description>
<repository type="git" url="https://g...content-available-to-author-only...b.com/AutoMapper/AutoMapper" commit="53faf3f014802b502f6a49b4c94368f478752f59" />
<dependencies>
<group targetFramework=".NETFramework4.6.1" />
<group targetFramework=".NETStandard2.0">
<dependency id="Microsoft.CSharp" version="4.5.0" exclude="Build,Analyzers" />
<dependency id="System.Reflection.Emit" version="4.3.0" exclude="Build,Analyzers" />
</group>
</dependencies>
<frameworkAssemblies>
<frameworkAssembly assemblyName="Microsoft.CSharp" targetFramework=".NETFramework4.6.1" />
</frameworkAssemblies>
</metadata>
</package>"""
if re.search(r'<licenseUrl>(?P<url>.*?)</licenseUrl>', content, flags=re.DOTALL or re.MULTILINE) is not None:
print('<licenseUrl> found using regex')
tree = ET.fromstring(content)
tag = tree.find('licenseUrl')
if tag is None:
print("tree.find('licenseUrl'): nothing found")
tags = tree.findall('*/licenseUrl')
if len(tags) == 0:
print("tree.findall('*/licenseUrl'): nothing found")
tags = tree.findall('.//licenseUrl')
if len(tags) == 0:
print("tree.findall('.//licenseUrl'): nothing found")
tags = tree.findall('licenseUrl')
if len(tags) == 0:
print("tree.findall('licenseUrl'): nothing found")
tag = tree.find('.//{*}licenseUrl')
if tag is None:
print("tree.find('.//{*}licenseUrl'): nothing found")