namespace Yes.Infrastructure.Rss { public static class XDocumentExtensions { public static string ToStringWithDeclaration(this XDocument doc) { if (doc.Declaration == null) return doc.ToString(); using var writer = new StringWriter(); doc.Save(writer); return writer.ToString(); } } }