Listing C



try{

            FileOutputStream OS = new FileOutputStream(strFileName);

            Properties OP =  OutputProperties.getDefaultMethodProperties("xml");

            OP.setProperty(OutputKeys.METHOD,"xml");

            OP.setProperty(OutputKeys.INDENT,"yes");

            org.apache.xalan.serialize.Serializer serializer = org.apache.xalan.serialize.SerializerFactory.getSerializer (OP);

            serializer.setOutputStream(OS);

            serializer.asDOMSerializer().serialize(doc);

            System.out.println("saved: " + strFileName);

            return true;

}catch(Exception e){

            e.printStackTrace();

            System.out.println(strFileName + "  Not Saved!!!");

            return false;

}