How to use this method:table.PreviousSibling.Runs.Insert

I have this document,I hope according to table to find the front caption of the table,then add text in front of the caption.
test caption
There is table
I want to add text in front of test caption,like this:
add text test capion
There is table
I have a code
table.PreviousSibling,but table.PreviousSiblingtables is Node type,He doesn’t include Runs,can not use table.PreviousSibling.Runs.Insert(0, run)

Help me,thanks

Hi Yizheng,

Thanks for your interest in Aspose.Words.

First of all I would suggest you to please read the following article to understand the structure of Nodes in Aspose.Words’ DOM:
https://docs.aspose.com/words/net/aspose-words-document-object-model/

Secondly, you can use the following code snippet to achieve this:

Document doc = new Document(@"C:\Temp\Source+file.docx");
Table tab = doc.FirstSection.Body.Tables[0];
Paragraph targetPara = tab.PreviousSibling as Paragraph;
Run run = new Run(doc, "add text ");
run.Font.Color = Color.Red;
targetPara.Runs.Insert(0, run);
doc.Save(@"C:\Temp\out.docx");

I hope, this helps.

Best regards,