Two nested tables only working when at least one node has data all the way down

Hello, I have a bulletin board like page where I try to export a thread into word using MailMerge. I’m trying to do this with regions and since a thread don’t have comments/replies from start I try to do remove the empty lines.

A thread can have 0 or more comments and the comments can have 0 or more replies. This works as long as the thread has at least one comment and 1 reply. The rest of the comments can have empty replies. If a use a template without replies there has to be at least 1 comment.

The XML structure looks like this:
- Thread
– Comments
— Comment
---- Replies
----- Reply

Before the merge I set MailMerge.RemoveEmptyRegions = true;

The only solution I can think of is using 3 templates.

  • One template when there are comments with replies
  • One template when there are no comments with replies
  • One template when there are no comments

Are there no other solution? I know how to remove unused MergeFields but I want to remove the whole table row from my template since it has background color.

This message was posted using Page2Forum from How-to: Use Nested Mail Merge Regions - Aspose.Words for .NET

Thanks for your inquiry. Could you please provide me the template and simple data which you use for generate the document and also simple code which will allow me to reproduce the problem on my side? I will check the problem on my side and provide you more information.
Best regards,

Thank you for replying I had some problems posting a reply yesterday. I think it might be because of the proxy I was behind. Here are some example code attached, hopefully explaining the problem.


Thanks for sharing the information. Please use the following code snippet to resolve your issue. Please let us know, If you have any more queries.

foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
    if (table.LastRow.LastCell.ToTxt().Trim() == "")

Thank you, it seems to be working