Hi,

I want to construct a XML document in memory and then write it to a file.
Here is my code trying to do it.

+++++++++++++++++++++++++++++++++++++++++++++++++++
            FileWriter output = new FileWriter("c:\test.xml");
            OutputFormat of = new OutputFormat("xml","UTF-8",true);

            XMLSerializer serializer = new XMLSerializer(output, of);

            Document dom = new DocumentImpl();

            Element root = dom.createElement("Target");
            root.setAttribute("name", sAppName);
            root.setAttribute("path", sPath);

            Element admin = dom.createElement("Administrator");
            admin.setAttribute("name", sName);
            admin.setAttribute("email", sEmail);
            root.appendChild(admin);

            serializer.serialize(dom);
            output.close();

+++++++++++++++++++++++++++++++++++++++++++++++++++++


I always get a empty file, the size of c:\test.xml is zero. 

Can someone shed some light on how to do it correctly?

Thanks a lot,

Keppel

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to