input: Write a function to parse the given URL and return the protocol, domain name, and path using Python. The function should accept a string representing a URL and return a dictionary with keys 'protocol', 'domain_name', and 'path' containing their respective values extracted from the URL. If the URL is invalid, the function should return None.
  assert parse_url('https://www.example.com/path/to/file')=={'protocol': 'https', 'domain_name': 'www.example.com', 'path': '/path/to/file'}
  assert parse_url('http://example.com')=={'protocol': 'http', 'domain_name': 'example.com', 'path': '/'}
  assert parse_url('')==None
  assert parse_url('invalid-url')==None
  assert parse_url('ftp://user:password@ftp.example.com/files')=={'protocol': 'ftp', 'domain_name': 'user:password@ftp.example.com', 'path': '/files'}
output: def parse_url(url):
      if not url:
          return None
      parts = url.split('://', 1)
      if len(parts) != 2:
          return None
      protocol, rest = parts
      if '/' in rest:
          domain_name, path = rest.split('/', 1)
          path = '/' + path
      else:
          domain_name, path = rest, '/'
      return {'protocol': protocol, 'domain_name': domain_name, 'path': path}