Created
May 24, 2014 17:31
-
-
Save jonsagara/5c4e2d744fb7f9c08ef3 to your computer and use it in GitHub Desktop.
Count OPML folders and feeds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Xml.Linq; | |
namespace OpmlStats.ConsoleApp | |
{ | |
class Program | |
{ | |
private const string OpmlFile = @"C:\Path\To\Your\OpmlFile.opml"; | |
static void Main(string[] args) | |
{ | |
var xDoc = XDocument.Load(OpmlFile); | |
var folders = xDoc.Element("opml").Element("body").Elements("outline"); | |
var folderCount = folders.Count(); | |
var feedCount = 0; | |
foreach (var folder in folders.OrderBy(f => f.Attribute("title").Value)) | |
{ | |
Console.WriteLine(folder.Attribute("title").Value); | |
var feeds = folder.Elements("outline"); | |
feedCount += feeds.Count(); | |
foreach (var feed in feeds.OrderBy(f => f.Attribute("title").Value)) | |
{ | |
Console.WriteLine("\t{0} - {1}", feed.Attribute("title").Value, feed.Attribute("xmlUrl").Value); | |
} | |
} | |
Console.WriteLine(); | |
Console.WriteLine("OPML Stats:"); | |
Console.WriteLine("\tFolders: {0}", folderCount); | |
Console.WriteLine("\tFeeds: {0}", feedCount); | |
Console.WriteLine("Press ENTER to quit..."); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment