input: Write a function to parse the given URL and return a dictionary containing the protocol, domain name, and path using Python. If the URL is invalid, return an empty dictionary.
  assert parse_url('https://www.example.com/path/to/file')=={'protocol': 'https', 'domain': 'www.example.com', 'path': '/path/to/file'}
  assert parse_url('http://invalid.url')=={}
  assert parse_url('')=={}
  assert parse_url(None)=={}
  assert parse_url('ftp://example.net/files')=={'protocol': 'ftp', 'domain': 'example.net', 'path': '/files'}
output: def parse_url(url):
      if not url:
          return {}
      parts = url.split('://')
      if len(parts) != 2:
          return {}
      protocol, rest = parts
      domain_path = rest.split('/', 1)
      domain = domain_path[0]
      path = '/' + domain_path[1] if len(domain_path) > 1 else '/'
      return {'protocol': protocol, 'domain': domain, 'path': path}