Arrh, okay. There's a couple of problems with the code I posted. You need to close both the file and the text writer to ensure they are disposed. Also the text writer is designed to be used to write elements indivdually. The easiest way to correct this is to pass by the DOM:
#light
open System.IO
open System.Xml
open System.Text
let main() =
use file = File.Create(@"C:\Documents and Settings\rpickering\My Documents\Visual Studio 2008\Projects\TestWriteXML\test.xml")
let xml = "<xml><toto>tete</toto></xml>"
let doc = new XmlDocument()
doc.LoadXml(xml)
use xw = new XmlTextWriter(file, Encoding.UTF8)
xw.Formatting <- Formatting.Indented;
doc.WriteTo(xw)
do main()
Robert Pickering, MVP
http://strangelights.com