NodeClone Method

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.7.0

Syntax

public Node Clone(
	bool isCloneChildren
)

Parameters

isCloneChildren
Type: SystemBoolean

Return Value

Type: Node

Examples

Shows how to clone composite nodes with and without their child nodes.
Document doc = new Document();
Paragraph para = doc.FirstSection.Body.FirstParagraph;
para.AppendChild(new Run(doc, "Hello world!"));

// Clone the paragraph and the child nodes
Node cloneWithChildren = para.Clone(true);

Assert.IsTrue(((CompositeNode)cloneWithChildren).HasChildNodes);
Assert.AreEqual("Hello world!", cloneWithChildren.GetText().Trim());

// Clone the paragraph without its clild nodes
Node cloneWithoutChildren = para.Clone(false);

Assert.IsFalse(((CompositeNode)cloneWithoutChildren).HasChildNodes);
Assert.AreEqual(string.Empty, cloneWithoutChildren.GetText().Trim());

See Also