Quantcast
Channel: Open XML Format SDK forum
Viewing all articles
Browse latest Browse all 1288

Locating a Content Control inside a table (or other element)

$
0
0

Hi Folks,

I have a simple word document that contains content controls (just plain text ones).  The issue that I am having is that some of the content controls are embedded in other elements (such as tables) and I am unable to find them in the document.

if I create a simple document that contains a PlainText content control called bob and put it in the root of the document and perform  the following:-

List<SdtBlock> blockList = mainDocumentPart.Document.Decendants<SdtBlock>().ToList()

I get one element returned which I can examine blockList[0].SdtProperties.GetFirstChild<Tag>() and I get a valid tag element back.

 

However, if I then add a table, then put another control inside called 'fred',  block list will contain 2 elements, but the second element will not contain a tag property. 

The fred block is nested several levels deep and I am looking for a way to find it (regardless of what it is nested in) so that I can update its contents?

Does anyone have a working way to do this


Viewing all articles
Browse latest Browse all 1288

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>