Free Support Forum -

How to get all the comments present in document

I am using aspose word 2.0 for java.
Is it possible to get handle of of all the comments present inside document?
I could not find any method similar to getBookmarks() in Document() class.


Hey Sunil,

You can get all comments (as well as any other nodes actually) from the document using GetChildNodes or SelectNodes method:

Document doc = new Document("MyDocument.doc");
NodeCollection comments = doc.getChildNodes(NodeType.COMMENT, true);

for (Node commentNode : comments)
Comment comment = (Comment) commentNode;
// ...

Thanks for the response.

Is it possible to get the nodes for Track changes deleted/ inserted text using this method ?
I am attaching the example document for it.


Yes, you can obtain paragraphs or runs containing inserted/deleted text in the following way:

NodeCollection runs = doc.GetChildNodes(NodeType.Run, true);

foreach (Run run in runs)


if (run.IsInsertRevision)


// run.Text is an inserted text...


else if (run.IsDeleteRevision)


// run.Text is a deleted text...