Different files, different jobs
Robots.txt supplies crawler access guidance. An XML sitemap lists preferred discoverable URLs. Neither file guarantees indexing, removes a page from search or protects confidential information.
Build conservative crawler rules
Avoid broad disallow rules unless their impact is understood. Keep important rendering resources available and use absolute sitemap URLs. Validate syntax before replacing a live file.
Keep sitemaps clean
List canonical, indexable URLs that return successful responses. Exclude redirects, duplicate filters and private areas. Submit the published sitemap in search-engine webmaster tools and update it when important URLs change.