range property

Node.range property

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


Shows how to delete all the nodes from a range.

doc = aw.Document()
builder = aw.DocumentBuilder(doc)

# Add text to the first section in the document, and then add another section.
builder.write("Section 1. ")
builder.write("Section 2.")

self.assertEqual("Section 1. \fSection 2.", doc.get_text().strip())

# Remove the first section entirely by removing all the nodes
# within its range, including the section itself.

self.assertEqual(1, doc.sections.count)
self.assertEqual("Section 2.", doc.get_text().strip())

See Also