@CaptDragon solution is right to generate kml file from features. if you want to save it client side, there is a tiny javascript + Flash library here. and very good example here, only one thing is that change data name to *.kml.
and the sample code with @CaptDragon's code and Downloadify:
<script type="text/javascript">
function GetKMLFromFeatures(features) {
var format = new OpenLayers.Format.KML({
'maxDepth':10,
'extractStyles':true,
'internalProjection': map.baseLayer.projection,
'externalProjection': new OpenLayers.Projection("EPSG:4326")
});
return format.write(features);
}
Downloadify.create('downloadify',{
filename: function(){
return document.getElementById('filename').value + '.kml';
},
data: function(){
return GetKMLFromFeatures(features);
},
onComplete: function(){
alert('Your File Has Been Saved!');
},
onCancel: function(){
alert('You have cancelled the saving of this file.');
},
onError: function(){
alert('You must put something in the File Contents or there will be nothing to save!');
},
transparent: false,
swf: 'media/downloadify.swf',
downloadImage: 'images/download.png',
width: 100,
height: 30,
transparent: true,
append: false
});
</script>
i hope it helps you...