Range

Node.Range property

Returns a Range object that represents the portion of a document that is contained in this node.

public Range Range { get; }

Examples

Shows how to delete all the nodes from a range.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Add text to the first section in the document, and then add another section.
builder.Write("Section 1. ");
builder.InsertBreak(BreakType.SectionBreakContinuous);
builder.Write("Section 2.");

Assert.That(doc.GetText().Trim(), Is.EqualTo("Section 1. \fSection 2."));

// Remove the first section entirely by removing all the nodes
// within its range, including the section itself.
doc.Sections[0].Range.Delete();

Assert.That(doc.Sections.Count, Is.EqualTo(1));
Assert.That(doc.GetText().Trim(), Is.EqualTo("Section 2."));

See Also