Do you have a real project you are working on, or you just want to look at any code example? If the latter, maybe you can find something here: http://www.xmlpitstop.com/default.asp?DataType=XMLEXAMPLES If you have a real project, than it becomes more complicated First, your database may have built-in features for converting tables to XML files, check it. If not, you have to do all the job yourself and you need: 1) design your XML structure; 2) access your database to read data; 3) when you have your data retrieved, as Bill said, either build XML tree or simply write to text file. Task #1: there are a lot of design considerations involved, �Professional XML databases� chapter1 and chapter2 are entirely dedicated to design stage. Task #2 is really specific to your database, There is no code that can read �a database�. Task #3 is, on the contrary, generic, any piece of code that construct XML tree will give you an idea. Here is an example. Did it help?