Content control with section break does not import into Aspose.Words' DOM using .NET

GetChildNodes method doesn’t lists the content control if content control has section break continuous.


class Program
{
static void Main(string[] args)
{
string filePath= Path.Combine(Environment.CurrentDirectory, “test1.docx”);
Document doc = new Document(filePath);
Console.WriteLine(doc.GetChildNodes(NodeType.StructuredDocumentTag, true).Count);
}
}

Attached a sample document which as two content control. However the above code returns the count as 1. The second content control has section break continuous.

This functionality is highly critical for our product. Will be much appreciated if you can give a fix / any solution to this problem.

Thanks,
Yuvaraj
Hi Yuvaraj,

Thanks for your inquiry. As per current Aspose.Words' document model, only sections can be inserted into Document node. Please check the detail of StructuredDocumentTag. StructuredDocumentTag can occur in a document in the following places:

  • Block-level - Among paragraphs and tables, as a child of a Body, HeaderFooter, Comment, Footnote or a Shape node.
  • Row-level - Among rows in a table, as a child of a Table node.
  • Cell-level - Among cells in a table row, as a child of a Row node.
  • Inline-level - Among inline content inside, as a child of a Paragraph.
  • Nested inside another StructuredDocumentTag.

Unfortunately, this feature is not compatible with our document model. We apologize for your inconvenience.

@vyuvarajnet

Starting from Aspose.Words 20.7, you can read the content control that contains the section break.We have added read only properties for content control that contains the section break in Aspose.Words 20.7. You can find the detail of these properties from here:

Please use following code example to get the title of content controls. Hope this helps you.

var doc = new Document(MyDir + "my_sample.docx");
foreach (StructuredDocumentTagRangeStart tag in doc.GetChildNodes(NodeType.StructuredDocumentTagRangeStart, true))
    Console.WriteLine(tag.Title);

foreach (StructuredDocumentTag tag in doc.GetChildNodes(NodeType.StructuredDocumentTag, true))
    Console.WriteLine(tag.Title);