Finding placeholders is difficult

Hello,

I’m trying to find placeholders in a Word document using the “.GetChildNodes(NodeType.Run, true)” method, for example, “{egov_Ticket}”, in order to apply logic to the next nodes.

However, in this example, this term is split across three different nodes. For instance, Node 1 = “{”, Node 2 = “egov_Ticket”, and Node 3 = “}”. This makes it impossible for me to find the desired word.

Even removing the formatting in the Word document doesn’t seem to work. The only solution I have found is to delete this term and manually rewrite it.

Is there any other solution for this?

Best regards

Here is the Document:
TestDok.docx (34,5 KB)

@AStelzner You can use the following code to make the placeholder to be represented as a single Run node:

Document doc = new Document(@"C:\Temp\in.docx");

FindReplaceOptions opt = new FindReplaceOptions();
opt.UseSubstitutions = true;
doc.Range.Replace("{egov_Ticket}", "$0", opt);

doc.Save(@"C:\Temp\out.docx");