Hi
Thanks for your inquiry. You can try using the following code to achieve this.
Document doc = new Document(@"Test138\in.doc");
//Get start node
Node startNode = doc.Range.Bookmarks["start"].BookmarkEnd;
//Get End node
Node endNode = doc.Range.Bookmarks["end"].BookmarkStart;
Node curNode = startNode.NextPreOrder(doc);
while (curNode!=null)
{
if (curNode.Equals(endNode))
break;
//move to next node
Node nextNode = curNode.NextPreOrder(doc);
//Check whether current contains end node
if (curNode.IsComposite)
{
if (!(curNode as CompositeNode).ChildNodes.Contains(endNode) &&
!(curNode as CompositeNode).ChildNodes.Contains(startNode))
{
nextNode = curNode.NextSibling;
curNode.Remove();
}
}
else
{
curNode.Remove();
}
curNode = nextNode;
}
//Save output document
doc.Save(@"Test138\out.doc");
Please let me know in case of any issues. Also please attach your document for testing.
Best regards.
Alexey Noskov
Developer/Technical Support
Aspose Auckland Team