HtmlAgilityPack.HtmlNode.CloneNode C# (CSharp) Method

CloneNode() public method

Creates a duplicate of the node and changes its name at the same time.
public CloneNode ( string newName ) : HtmlNode
newName string The new name of the cloned node. May not be null.
return HtmlNode
		public HtmlNode CloneNode(string newName)
		{
			return CloneNode(newName, true);
		}

Same methods

HtmlNode::CloneNode ( bool deep ) : HtmlNode
HtmlNode::CloneNode ( string newName, bool deep ) : HtmlNode

Usage Example

        internal void InternalTrace(object Value)
        {
            if (!Trace)
            {
                return;
            }
            string     name = null;
            StackFrame sf   = new StackFrame(1, true);

            name = sf.GetMethod().Name;
            string nodename;

            if (_currentnode == null)
            {
                nodename = "(null)";
            }
            else
            {
                nodename = _currentnode.Name;
            }
            string nodevalue;

            if (_currentnode == null)
            {
                nodevalue = "(null)";
            }
            else
            {
                switch (_currentnode.NodeType)
                {
                case HtmlNodeType.Comment:
                    nodevalue = ((HtmlCommentNode)_currentnode).Comment;
                    break;

                case HtmlNodeType.Document:
                    nodevalue = "";
                    break;

                case HtmlNodeType.Text:
                    nodevalue = ((HtmlTextNode)_currentnode).Text;
                    break;

                default:
                    nodevalue = _currentnode.CloneNode(false).OuterHtml;
                    break;
                }
            }
            System.Diagnostics.Trace.WriteLine("oid=" + GetHashCode()
                                               + ",n=" + nodename
                                               + ",a=" + _attindex + ","
                                               + ",v=" + nodevalue + ","
                                               + Value, "N!" + name);
        }
All Usage Examples Of HtmlAgilityPack.HtmlNode::CloneNode