Hei..i am novice to programming. How to generate beautiful html pages from a text file. My idea is to generate XML first and then generate it to html. Generated html page should contain all the information that the text file contains..like tables,pics,body,headings. I dont have a clue what to do after i read XML file using 'open'. plz help.

A nice tool is sphinx which converts text written in rich text format to html.

from xml.sax.saxutils import XMLGenerator

I have no experience with the XMLGenerator, but I know it is used to create xml files.

Use any of the known markup languages to write the text file (reStructuredText, MarkDown, Kiwi ...) and use the corresponding tool to convert it to HTML (Docutils, MarkDown for Python, http://www.ivy.fr/kiwi/). You can also use those tools' API to integrate them in your own app. You don't need no XML step in between.