I am inserting a clone of a paragraph just before the original paragraph in a document. I am locating the paragraph to clone by using bookmarks. When I insert the clone of the paragraph, it maintains the bookmarks, which I don't want it to do. So, I am attempting to remove the bookmarkstart and bookmarkend nodes from the clone by iterating through the collection of child nodes of the paragraph. Though I am getting back the collection of nodes in that paragraph (bookmarkstart/end, runs), the foreach loop only iterates through the collection once for the bookmarkstart then exits, but not for the runs or the bookmarkend.
Paragraph newPara = (Paragraph)para.Clone(true);
NodeCollection nc = newPara.GetChildNodes(NodeType.Any, true);
foreach (Node n in nc){
if (n.NodeType == NodeType.BookmarkStart || n.NodeType == NodeType.BookmarkEnd){
newPara.ChildNodes[n.ParentNode.IndexOf(n)].Remove();
}
}
This message was posted using Aspose.Live 2 Forum