private async void BtnCompare_Click(object sender, RoutedEventArgs e) { try { // First load the html into a document objects we can manipulate string html1 = await File.ReadAllTextAsync("Resources/bbc1.html"); HtmlDocument doc1 = new HtmlDocument(); doc1.LoadHtml(html1); string html2 = await File.ReadAllTextAsync("Resources/bbc2.html"); HtmlDocument doc2 = new HtmlDocument(); doc2.LoadHtml(html2); // Filter the html to remove parts that are not very interesting HtmlFilter filter = new HtmlFilter(); filter.CleanHtml(doc1.DocumentNode); filter.CleanHtml(doc2.DocumentNode); // convert the html into lines HtmlConverter converter = new HtmlConverter(); var lines1 = converter.GetLines(doc1.DocumentNode, ConvertOptions.Default); var lines2 = converter.GetLines(doc2.DocumentNode, ConvertOptions.Default); // find the difference between these 2 sets of lines LineDiffer differ = new LineDiffer(); var diffResult = differ.GetDiff(lines1, lines2, true); // load the original html into a document again HtmlDocument originalDoc = new HtmlDocument(); originalDoc.LoadHtml(html1); // highlight the changed parts of the document Highlighter.ApplyHighlights(originalDoc, "#FFFF99", diffResult.Added.Select(i => i.Line.XPath)); string htmlHighlighted = originalDoc.Save(); webBrowserDiff.NavigateToString(htmlHighlighted); } catch (Exception ex) { MessageBox.Show(ex.Message); } }