StructuredDocumentTag Not Able to Read from Dcoument

MASTER SERVICES AGREEMENT BETWEEN.docx (29.6 KB)

Hi Team,

attached document have 4 content control. But When I try to read , Aspose not give any result. Below code I use to get control

 List<Aspose.Words.Markup.StructuredDocumentTag> findControl = doc1.GetChildNodes(Aspose.Words.NodeType.StructuredDocumentTag, true).Cast<Aspose.Words.Markup.StructuredDocumentTag>().ToList()
            .Where(x => x.Title.Contains("OCC_")).ToList();

it get 0 count.
My Aspose Version is V22.3

@Vipin_Paliwal In your document there are two structured document tags that spans several sections. In this case Aspose.Words represents such SDTs with StructuredDocumentTagRangeStart and StructuredDocumentTagRangeEnd nodes. That is why you do not get these SDTs when use doc.GetChildNodes(NodeType.StructuredDocumentTag, true).

// Regular SDTs
NodeCollection sdts = doc.GetChildNodes(NodeType.StructuredDocumentTag, true);
Console.WriteLine(sdts.Count);
foreach(StructuredDocumentTag sdt in sdts)
    Console.WriteLine(sdt.Title);

// Starts of SDTs spanned multiple sections
NodeCollection sdtStart = doc.GetChildNodes(NodeType.StructuredDocumentTagRangeStart, true);
Console.WriteLine(sdts.Count);
foreach (StructuredDocumentTagRangeStart start in sdtStart)
    Console.WriteLine(start.Title);

Hi Team,

In our system, user can add control to select multiple paragraph. Then how can we handle this?

@Vipin_Paliwal Multiple paragraph is not an issue. StructuredDocumentTagRangeStart and StructuredDocumentTagRangeEnd are used when the SDT spans several sections (see the screenshot I have provided in my previous answer). You can see it in MS Word too:

To read content of such SDT, you should read content between the corresponding StructuredDocumentTagRangeStart and StructuredDocumentTagRangeEnd nodes.

Thanks for your reply. I am able to resolved.

1 Like