You can also do:

    if urlname.endswith('.xml'):