We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Repeating section functionality

Hello, is there any news on this? We would also like to use the repeating section functionality but were not able to find examples or information on how to use it.


I am afraid, your query is not clear enough. We request you to please elaborate your query further by providing complete details of your usecase. Please also ZIP and attach your sample input and expected documents here for our reference. This will help us to understand the scenario on our end and we will be in better position to address your question accordingly.


We would like to use the repeating section content control but we cannot find any documentation about it on the Aspose website. So, currently we do not have any code where we use it since we don’t know how to use it …

We were able to find documentation on how to use the PlainText, Picture, … content controls on this page: https://docs.aspose.com/display/wordsnet/Working+with+Content+Control+SDT. But that page does not show a code example for a repeating section content control.

So what we need is a good (code) example, showing the usage of a repeating section content control API in Aspose.Words.



I am afraid, the requested feature is not available at the moment. We will provide a way in future to add a new repeating section content control programmatically. Your thread has been linked to the appropriate issue (WORDSNET-12439) and we will inform you via this thread as soon as this is supported. We apologize for your inconvenience.

Hello, just to make sure that there are no minsunderstandings: we do not want to add a new repeating section content control, we do want to use an existing repeating section content control. So the Word document already contains such a control, we just want to fill it in with repeating content.


We have logged your requirement in our issue tracking system. Your ticket number is WORDSNET-17622 . We will further look into the details of this requirement and will keep you updated on the status of the linked issues.


Regarding WORDSNET-17622, please see these sample documents (Repeating Section Content Control.zip (30.7 KB)) and try running the following code:

Document doc = new Document("D:\\Temp\\Repeating Section Content Control.docx");

Table table = doc.FirstSection.Body.Tables[0];

StructuredDocumentTag repeatingSection = (StructuredDocumentTag)table.GetChild(NodeType.StructuredDocumentTag, 0, false);
Debug.Assert(repeatingSection != null && repeatingSection.SdtType == SdtType.RepeatingSection);
StructuredDocumentTag repeatingItem = (StructuredDocumentTag)repeatingSection.GetChild(NodeType.StructuredDocumentTag, 0, false);
Debug.Assert(repeatingItem != null);

StructuredDocumentTag[] repeatingSdts = new StructuredDocumentTag[4];
int i = 0;
foreach (StructuredDocumentTag sdt in repeatingItem.GetChildNodes(NodeType.StructuredDocumentTag, true))
    repeatingSdts[i] = sdt;

Debug.Assert(repeatingSdts.Length == 4);

const string xml =
    @"<?xml version=""1.0"" encoding=""utf-8""?>
        <Name>John Doe</Name>
        <Name>Jane Adams</Name>
        <Name>John Smith</Name>

CustomXmlPart customXmlPart = doc.CustomXmlParts.Add(Guid.NewGuid().ToString("B"), xml);

repeatingSection.XmlMapping.SetMapping(customXmlPart, "/root/Employee", null);
repeatingSdts[0].XmlMapping.SetMapping(customXmlPart, "/root/Employee/Name", null);
repeatingSdts[1].XmlMapping.SetMapping(customXmlPart, "/root/Employee/HireDate", null);
repeatingSdts[2].XmlMapping.SetMapping(customXmlPart, "/root/Employee/Gender", null);
repeatingSdts[3].XmlMapping.SetMapping(customXmlPart, "/root/Employee/Department", null);


Hope, this helps.