public HtmlNode CloneNode(bool deep) { HtmlNode node = _ownerdocument.CreateNode(_nodetype); node.Name = Name; switch (_nodetype) { case HtmlNodeType.Comment: ((HtmlCommentNode)node).Comment = ((HtmlCommentNode)this).Comment; return(node); case HtmlNodeType.Text: ((HtmlTextNode)node).Text = ((HtmlTextNode)this).Text; return(node); } if (HasAttributes) { foreach (HtmlAttribute attribute in (IEnumerable <HtmlAttribute>)_attributes) { HtmlAttribute newAttribute = attribute.Clone(); node.Attributes.Append(newAttribute); } } if (HasClosingAttributes) { node._endnode = _endnode.CloneNode(false); foreach (HtmlAttribute attribute3 in (IEnumerable <HtmlAttribute>)_endnode._attributes) { HtmlAttribute attribute4 = attribute3.Clone(); node._endnode._attributes.Append(attribute4); } } if (deep) { if (!HasChildNodes) { return(node); } foreach (HtmlNode node2 in (IEnumerable <HtmlNode>)_childnodes) { HtmlNode newChild = node2.Clone(); node.AppendChild(newChild); } } return(node); }