code: def patch_file(actions, tree):
      
      tree = etree.parse(tree)
  
      if isinstance(actions, six.string_types):
          # It's a string, so it's a filename
          with open(actions) as f:
              actions = f.read()
      else:
          # We assume it's a stream
          actions = actions.read()
  
      actions = patch.DiffParser().parse(actions)
      tree = patch_tree(actions, tree)
      return etree.tounicode(tree)
docs: Takes two filenames or streams, one with XML the other a diff