Skip to content

Instantly share code, notes, and snippets.

@jstadnicki
Created June 12, 2016 14:47
public List<RssChannel> ParseToRssChannelList(OpmlImporterIndexDto dto)
{
var outlines = this.opmlHandler.GetOutlines(dto.ImportFile.InputStream);
var ot = this.FilterOutInvalidOutlines(outlines);
var urls = ot.Select(o =>
new RssChannel(
o.Attributes.GetNamedItem("xmlUrl").Value,
o.Attributes.GetNamedItem("title").Value))
.ToList();
return urls;
}
public List<XmlNode> FilterOutInvalidOutlines(IEnumerable<XmlNode> outlines)
{
var validoutlines = outlines.Where(o =>
o.Attributes.GetNamedItem("xmlUrl") != null
&& o.Attributes.GetNamedItem("title") != null
&& !String.IsNullOrWhiteSpace(o.Attributes.GetNamedItem("xmlUrl").Value)
&& !String.IsNullOrWhiteSpace(o.Attributes.GetNamedItem("title").Value));
return validoutlines.ToList();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment