Can you maybe tell us a few more details? We can tell you all about how to make a TOC in InDesign, it's pretty easy & pretty powerful. We can also tell you all about how to autotag for XML in InDesign. However, I can't guess how those two things would be releated, in your request, unless you tell us how they are related in your project.
As Joel's offered, it's not like you can do both functions in one fell swoop. Not that I suspect you'd particularly want to, because it'd be hard to get well-formed XML from your Table of Contents setup anyway.
If you're looking for suggestions for a workflow, I can help there.
First you want to develop a comprehensive and all-encompassing set of paragraph styles to incorporate all the text in your target document. Keep in mind that you want a style/tag for everything in the document to ensured your well formed XML document.
Apply the styles to everything in the InDesign document. The best way to do that is to select all the text and apply the most common text style/XML tag to everything in the document. Then apply your other styles/tags as exceptions where appropriate. You'll have to manually tag graphics later, and may/should have to apply them manually to tables, but this at least ensures that all your text has styles/XML tags fodder applied up front.
Since styles are now applied everywhere in your document, generating your ToC should be easy. Use the appropriate styles you want to break out to generate your ToC, considering whether you want to incorporate the same styles for tagging your ToC content to coincide with your text style/tags. When you create a ToC it essentially creates a separate "story"/text thread you can either label it as such later as a separate article/story, or select all the text and cut/paste it into the start of the main document thread to incorporate it all in the same article/story, as you prefer.
With all the text formatting/threading done, it's time to turn the document into XML structure. Map your styles to tags, manually tag your graphics/tables. Toss your story/article tags into the top/bottom of the thread(s) and be done with it.