DocumentBuilderCurrentNode Property
Gets the node that is currently selected in this DocumentBuilder.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.12
Syntax
public Node CurrentNode { get; }

Property Value

Type: Node
Remarks

CurrentNode is a cursor of DocumentBuilder and points to a Node that is a direct child of a Paragraph. Any insert operations you perform using DocumentBuilder will insert before the CurrentNode.

When the current paragraph is empty or the cursor is positioned just before the end of the paragraph, CurrentNode returns null.

Examples
Shows how to move between nodes and manipulate current ones.
Document doc = new Document(MyDir + "DocumentBuilder.WorkingWithNodes.doc");
DocumentBuilder builder = new DocumentBuilder(doc);

// Move to a bookmark and delete the parent paragraph.
builder.MoveToBookmark("ParaToDelete");
builder.CurrentParagraph.Remove();

FindReplaceOptions options = new FindReplaceOptions
{
    MatchCase = false,
    FindWholeWordsOnly = true
};

// Move to a particular paragraph's run and replace all occurrences of "bad" with "good" within this run.
builder.MoveTo(doc.LastSection.Body.Paragraphs[0].Runs[0]);
Assert.IsTrue(builder.IsAtStartOfParagraph);
Assert.IsFalse(builder.IsAtEndOfParagraph);
builder.CurrentNode.Range.Replace("bad", "good", options);

// Mark the beginning of the document.
builder.MoveToDocumentStart();
builder.Writeln("Start of document.");

// builder.WriteLn puts an end to its current paragraph after writing the text and starts a new one
Assert.AreEqual(2, doc.FirstSection.Body.Paragraphs.Count);
Assert.IsTrue(builder.IsAtStartOfParagraph);
Assert.IsTrue(builder.IsAtEndOfParagraph);

// builder.Write doesn't end the paragraph
builder.Write("Second paragraph.");

Assert.AreEqual(2, doc.FirstSection.Body.Paragraphs.Count);
Assert.IsFalse(builder.IsAtStartOfParagraph);
Assert.IsTrue(builder.IsAtEndOfParagraph);

// Mark the ending of the document.
builder.MoveToDocumentEnd();
builder.Writeln("End of document.");

doc.Save(ArtifactsDir + "DocumentBuilder.WorkingWithNodes.doc");
See Also