Create an XML file.

    Takes a path to where the XML file should be created
    and a metadata dictionary.

def pydict2xml(filename, metadata_dict, **kwargs):
    """Create an XML file.

    Takes a path to where the XML file should be created
    and a metadata dictionary.
    """
    try:
        f = open(filename, 'w')
        f.write(pydict2xmlstring(metadata_dict, **kwargs).encode('utf-8'))
        f.close()
    except:
        raise MetadataGeneratorException(
            'Failed to create an XML file. Filename: %s' % (filename)
        )