public static async Task SaveOPMLFile(StorageFile libraryFile) { var document = new Windows.Data.Xml.Dom.XmlDocument(); var rootNode = document.CreateElement("opml"); rootNode.AddAttribute("version", "1.1"); document.AppendChild(rootNode); var headNode = document.CreateElement("head"); headNode.AddChildWithInnerText("title", "Generated by Cast"); headNode.AddChildWithInnerText("dateCreated", DateTime.Now.ToString(CultureInfo.InvariantCulture)); rootNode.AppendChild(headNode); var bodyNode = document.CreateElement("body"); rootNode.AppendChild(bodyNode); foreach (var category in Categories) { var categoryNode = document.CreateElement("outline"); bodyNode.AppendChild(categoryNode); categoryNode.AddAttribute("text", category); foreach (var podcast in Podcasts.Where(p => p.Category == category)) { var podcastNode = document.CreateElement("outline"); categoryNode.AppendChild(podcastNode); podcastNode.AddAttribute("title", podcast.Title); podcastNode.AddAttribute("type", "rss"); podcastNode.AddAttribute("text", podcast.FeedUrl); podcastNode.AddAttribute("xmlUrl", podcast.FeedUrl); } } await document.SaveToFileAsync(libraryFile); }