How do I print DOM tree contents

Hello,
I have the following code. I am able to find the code to build a DOM tree.
My problem is:
1) How do I set the version
2)  how do I print it?

The commented 2 lines code is borrowed for IBM DOM parsers:
com.ibm.xml.parser.TXDocument

I downloaded javax xml libraries from SUN.com which contain w3c packages.
Appreciate if you can tell me the equivalent calls in W3c.
I donot have com.ibm.xml.parser.TXDocument
Naga
naga@firstip.com

import javax.xml.parsers.*;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
import org.w3c.dom.ProcessingInstruction;
import java.io.*;


public class MakeDocumentWithFactory {
          public static void main(String[] argv) {
              try {
                    DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();
                    DocumentBuilder db = dbf.newDocumentBuilder();
                    Document doc = db.newDocument();
                    Element root = doc.createElement("person");
                    Element item = doc.createElement("name");
                    item.appendChild(doc.createTextNode("Naga"));
                    root.appendChild(item);
                    doc.appendChild(root);
                    //Q1 ((TXDocument)doc).setVersion("1.0");
                   // Q2 ((TXDocument)doc).printWithFormat(new
PrintWriter(System.out));

                   }
               catch(Exception e) {
                         e.printStackTrace();
                   }
           }
  }

Received on Friday, 27 April 2001 19:08:20 UTC