public static string WriteXML <T>(T item, string xmlPath) { XmlSerializer xmlSerializer = new XmlSerializer(item.GetType()); try { FileStream fileStream = File.Create(xmlPath); fileStream.Close(); TextWriter textWriter = new StreamWriter(xmlPath, false, Encoding.UTF8); XmlSerializerNamespaces xmlSerializerNamespaces = new XmlSerializerNamespaces(); xmlSerializerNamespaces.Add(string.Empty, string.Empty); xmlSerializer.Serialize(textWriter, item, xmlSerializerNamespaces); textWriter.Flush(); textWriter.Close(); } catch (Exception e) { TLogger.LogException(e); } return(TXmlHelper.SerializeToXmlStr <T>(item, true)); }