docs: def pydict2xmlstring(metadata_dict, **kwargs):
      """Create an XML string from a metadata dictionary."""
      ordering = kwargs.get('ordering', UNTL_XML_ORDER)
      root_label = kwargs.get('root_label', 'metadata')
      root_namespace = kwargs.get('root_namespace', None)
      elements_namespace = kwargs.get('elements_namespace', None)
      namespace_map = kwargs.get('namespace_map', None)
      root_attributes = kwargs.get('root_attributes', None)
      # Set any root namespace and namespace map.
      if root_namespace and namespace_map:
          root = Element(root_namespace + root_label, nsmap=namespace_map)
      elif namespace_map:
          root = Element(root_label, nsmap=namespace_map)
      else:
          root = Element(root_label)
      # Set any root element attributes.
      if root_attributes:
          for key, value in root_attributes.items():
              root.attrib[key] = value
      # Create an XML structure from field list.
      for metadata_key in ordering:
          if metadata_key in metadata_dict:
              for element in metadata_dict[metadata_key]:
                  if 'content' in element and 'qualifier' in element:
                      create_dict_subelement(
                          root,
                          metadata_key,
                          element['content'],
                          attribs={'qualifier': element['qualifier']},
                          namespace=elements_namespace,
                      )
                  elif 'content' in element and 'role' in element:
                      create_dict_subelement(
                          root,
                          metadata_key,
                          element['content'],
                          attribs={'role': element['role']},
                          namespace=elements_namespace,
                      )
                  elif 'content' in element and 'scheme' in element:
                      create_dict_subelement(
                          root,
                          metadata_key,
                          element['content'],
                          attribs={'scheme': element['scheme']},
                          namespace=elements_namespace,
                      )
                  elif 'content' in element:
                      create_dict_subelement(
                          root,
                          metadata_key,
                          element['content'],
                          namespace=elements_namespace,
                      )
      # Create the XML tree.
      return '<?xml version="1.0" encoding="UTF-8"?>\n' + tostring(
          root,
          pretty_print=True
      )