private void HighlightSingle(string xpath) { try { var hnode = SessionDocument.Current.SelectSingleNode(xpath); var node = SessionDocument.Descendants().Where(x => x.Current == hnode) .FirstOrDefault() as HtmlNodeHierarchy; if (node != null) { node.Highlight = Brushes.Red; } hnode = DomDocument.Current.SelectSingleNode(xpath); node = DomDocument.Descendants().Where(x => x.Current == hnode) .FirstOrDefault() as HtmlNodeHierarchy; if (node != null) { node.Highlight = Brushes.Red; } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } NotifyPropertyChanged("SessionDocument"); NotifyPropertyChanged("DomDocument"); }
private void Highlight(string xpath) { try { bool nodefound = false; var sessNodes = SessionDocument.Current.SelectNodes(xpath); if (sessNodes != null) { foreach (HtmlNodeHierarchy node in SessionDocument.Descendants()) { node.Highlight = sessNodes.Contains(node.Current) ? Brushes.Yellow : Brushes.Transparent; } nodefound = true; } var domNodes = DomDocument.Current.SelectNodes(xpath); if (domNodes != null) { foreach (HtmlNodeHierarchy node in DomDocument.Descendants()) { node.Highlight = domNodes.Contains(node.Current) ? Brushes.Yellow : Brushes.Transparent; } nodefound = true; } if (!nodefound) { MessageBox.Show("null nodes"); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } NotifyPropertyChanged("SessionDocument"); NotifyPropertyChanged("DomDocument"); }