Hi,
I’m having trouble trying to exclude some node types from a document. So just for testing, i tried to select all the node types listed in your library, and deleting all the ones that weren’t of those types. As shown in the following example:
Document doc = new Document("test.docx");
NodeCollection srcNodes = doc.GetChildNodes(NodeType.Any, true);
foreach (Node srcNode in srcNodes)
{
if ( srcNode.NodeType != NodeType.Document
|| srcNode.NodeType != NodeType.Section
|| srcNode.NodeType != NodeType.Body
…
|| srcNode.NodeType != NodeType.OfficeMath
)
srcNode.Remove();
}
What ends up happening here is that the output document is empty. Despite me including all the 32 node types. And I’ve no clue why it is so.
Second problem:
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
foreach (Aspose.Words.Drawing.Shape shape in shapes)
{ shape.Remove();
/*if (true)
{
shape.Remove();
}*/
}
This code doesn’t delete all the shapes in a document. Some images remain, I cannot figure out why that is.
Deep gratitude if you can look into these issues, thanks.