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:
Thanks for your inquiry. Perhaps you’re using an older version of Aspose.Words; I would suggest you please upgrade to the latest version of Aspose.Words i.e. 13.7.0. You can download it from the following link: https://releases.aspose.com/words/net
Hi Awais, thanks for the response.
I’m running Aspose.Words 13.7 so it shouldn’t be a version issue.
Now about the issue with the Shape nodes, I’m still struggling with this.
When I step into the running program the shapes.Count variable is actually 0. So the program can’t even find any shapes in the document. I tried to exclude everything else by making a blank word document with just one image inserted to it, but it can’t find it, never mind removing it.
Any idea why that is?
Regards
Hi,
Thanks for your inquiry. Newer Microsoft Word documents (such as DOCX) may contain a different type of image container called DrawingML. You can filter such images by using NodeType.DrawingML. I hope, this helps.
Best regards,
But still about my first inquiry(the first code example) I’m having problems. It seems to remove the entire document, despite me seemingly including all the 32 node types in the if clause.
Hi,
Thanks for your inquiry. The problem occurs because of incorrect usage of conditional OR operator. In this case, you put “srcNode.NodeType != NodeType.Document” at the top which causes the control to always enter inside the body of IF block for every node in “srcNodes” collection. Also, as the first node in “srcNodes” collection is of type Section, it removes the whole Section with all it’s child nodes. I would suggest you please take a look at the tree representation of Document in DOM hierarchy: Document Tree Navigation
Best regards,