Need help preparing a 'Sitemap.xml' file using a Rake

After having my websites up for a few months and wondering why my
content is not exposed through search engines, I discovered SITEMAPS!
I've done a Google for explanations of how this is accomplished and
found these links;

These are either not current Rails 2.? explanations or are too
esoteric for me to follow.

I've written the logic to travel through my database and build the
various links but I don't know how to;

1. Write this into a Rake task
2. deliver the output to a xml file
3. format the xml file to behave the way Google wants

My plan is to download the data files from my website onto my desktop
computer. Run the Rake procedure and then simply upload the
sitemap_??.xml files.
Hopefully, someone could teach me how to build the index file to
compliment these.

I'm 'between a rock and a hard place' on this one and am willing to
pay someone for guidance.