protected bool IsAncestorLink(IElement element) { IElement parent = element.ParentElement; if (parent == null) { return(false); } List <INode> ancestors = element.Ancestors().ToList(); return(ancestors.Any(ancestor => ancestor.NodeName == "BUTTON" || ancestor.NodeName == "I" || ancestor.NodeName == "A")); }
private void ReplaceNodeWithTemplateNode(IElement inNode, string inTemplateFileName) { //Clone node and get required content out of it var tmpNewNode = (IElement)inNode.Clone(true); foreach (var tmpClass in tmpNewNode.ClassList.ToList()) { tmpNewNode.ClassList.Remove(tmpClass); } var tmpDict = new Dictionary <string, string>() { { "classes", string.Join(" ", inNode.ClassList) }, { "contents", tmpNewNode.OuterHtml }, }; var tmpNewNodeHtml = Template(inTemplateFileName, tmpDict); inNode.Replace(CreateFromHtml(tmpNewNodeHtml, inNode.Ancestors().First() as IElement)); }