ciao a tutti ho scritto il seguente codice

package it.provaDOM;

import javax.xml.parsers.*;
import org.w3c.dom.*;

public class XmlCreateDoc {

public static void main(String[] args) throws Exception {

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder domParser = factory.newDocumentBuilder();

Document doc = domParser.newDocument();
Element dir = doc.createElement("dir");
Element file = doc.createElement("file");

doc.appendChild(dir);
dir.appendChild(file);

System.out.println("fine");

}

}

che se non sbaglio dovrebbe rappresentare la seguente struttura

<dir>
<file></file>
</dir>

se è giusto vorrei salvarla su file. Mi spiegate come che in giro ho trovato poco fin ora?