Add a new button to the ToolStrip control and write the
following code:
private
void
mostFrequentWordToolStripButton_Click(object
sender, EventArgs
e)
{
if
(xml != null)
{
Regex
tagMatch = new
Regex("<[^>]+>",
RegexOptions.Compiled);
char[]
delimiterChars = { ' ',
',',
'.',
':',
'\t',
'\n',
'\r',
'\\',
'/'
};
var
mostFrequent =
(from
item in
xml.Element("rss").Element("channel").Elements("item")
let
description = item.Element("description").Value
let
withoutTags = tagMatch.Replace(description,
" ")
from
word in
withoutTags.Split(delimiterChars,
StringSplitOptions.RemoveEmptyEntries)
group
word by
word into
groups
orderby groups.Count()
descending
select
new
{ Word = groups.Key, Count = groups.Count() })
.First();
MessageBox.Show(string.Format("{0}:
{1}", mostFrequent.Word,
mostFrequent.Count));
}
}