Find Content Controls by Title

Document doc = new Document(OutputFile);
DocumentBuilder builder = new DocumentBuilder(doc);

        Node[] tags = doc.GetChildNodes(NodeType.StructuredDocumentTag, true).ToArray();

Looping through this array of nodes allows you to get values but it does not allow you to look up the Title of the structured document tag. There is no exposed member that lets me access the title of the document tag despite showing in the debugger. How can I search the document for the title of each structure document tag programmatically.

1.png (12.3 KB)
2.png (6.8 KB)
3.png (44.2 KB)

@NestedRAID

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

BillJacket_ToolTipDemo.pdf (860.3 KB)

Word document attached. Output file doesnt exist because I am trying to find the title off the content control which is done programmatically. Console application doesnt provide a solution and is just used for testing. With the word document I have included your developers should be able to create a console application that allows me to access the title of the structured document tag node in aspose.word.

@NestedRAID

You have shared PDF document. Please ZIP and attach your input Word document and sample code example for testing.

Says I am not Bill Jacket Content Control Testing.zip (21.4 KB)

public static void CreateBillJacket()
{
Document doc = new Document(OutputFile);
DocumentBuilder builder = new DocumentBuilder(doc);

        Node[] tags = doc.GetChildNodes(NodeType.StructuredDocumentTag, true).ToArray();
        // N-ary tree. Nodes can be 0..N / 0..* 

        foreach (Node node in tags)
        {
            var here = node.GetType().GetMethod("get_Title");
            var hereName = here.Name;

            // pointer to next node
            Node p1 = node.NextSibling;

            Console.WriteLine(node.GetText());
            while(p1 != null)
            {
                Console.WriteLine(p1.GetText());

                try
                {
                    p1 = p1.NextSibling.NextSibling;
                    Console.WriteLine(p1.GetText());
                }
                catch (Exception e)
                {
                    break;
                }
            }

            PropertyInfo nodePropertyInfo = node.GetType().GetProperty("Title");
            MethodInfo[] nodeMethodInfo = node.GetType().GetMethods();

            foreach (MethodInfo methodInfo in nodeMethodInfo)
            {
                Console.WriteLine(methodInfo.Name);

                if (methodInfo.Name == "get_Title")
                {
                    Console.WriteLine("found");
                }
            }

            if (nodePropertyInfo != null)
            {
                Console.WriteLine(nodePropertyInfo.GetValue("Title"));
                Console.WriteLine(nodePropertyInfo.Name + " " + node.GetText());
            }
        }
    }

@NestedRAID

Please use StructuredDocumentTag.Title property to get the title of content control as shown below.

Document doc = new Document(MyDir + "Bill Jacket Content Control Testing.docx");

foreach (StructuredDocumentTag sdt in doc.GetChildNodes(NodeType.StructuredDocumentTag, true).ToArray())
{
    Console.WriteLine("Title of content control : " + sdt.Title);
}

In your document, the title of content controls is not set. So, this property will return empty string.

That is what I am looking for thank you.