public static void WriteRSS(Rss value, Stream destination) { XmlSerializerNamespaces xsn = new XmlSerializerNamespaces(); xsn.Add("atom", "http://www.w3.org/2005/Atom"); xsn.Add("dc", "http://purl.org/dc/elements/1.1/"); xsn.Add("content", "http://purl.org/rss/1.0/modules/content/"); XmlSerializer ser = new XmlSerializer(value.GetType()); ser.Serialize(destination, value, xsn); }
private static string SerializeRss(Rss rss) { var ns = new XmlSerializerNamespaces(); foreach (var item in Rss.XmlNamespaces) { ns.Add(item.Key, item.Value); } var serializer = new XmlSerializer(rss.GetType()); using (var writer = new Utf8StringWriter()) { serializer.Serialize(writer, rss, ns); return(writer.ToString()); } }