use this code to serialize any object into a file stream ... in your case replace the Object type into HtmlElement
Object obj=new Object();
XmlSerializer sw = new XmlSerializer(typeof(Object));
FileStream fs = new FileStream("**Full FilePath**", FileMode.OpenOrCreate);
sw.Serialize(fs, obj);
fs.Close();
hope this helped,good luck.