Hi,
What is the fastest way to check whether two content controls data are same or not, where content control data format can be anything (text, table ,etc)
Thanks
Please see these input/output Word documents (Docs.zip (23.4 KB)) and try running the following code:
// load main document containing content controls data
Document doc = new Document("E:\\temp\\SDTs.docx");
// Get the two content controls you want to compare datas of
StructuredDocumentTag sdt1 = (StructuredDocumentTag) doc.GetChildNodes(NodeType.StructuredDocumentTag, true)[0];
StructuredDocumentTag sdt2 = (StructuredDocumentTag)doc.GetChildNodes(NodeType.StructuredDocumentTag, true)[1];
// Create a couple of temporary documents
Document tempDoc1 = new Document();
Document tempDoc2 = new Document();
// copy first content control in first temp document
StructuredDocumentTag importedSdt1 = (StructuredDocumentTag) tempDoc1.ImportNode(sdt1, true);
tempDoc1.FirstSection.Body.AppendChild(importedSdt1);
// copy second content control in second temp document
StructuredDocumentTag importedSdt2 = (StructuredDocumentTag)tempDoc2.ImportNode(sdt2, true);
tempDoc2.FirstSection.Body.AppendChild(importedSdt2);
// Now compare these two temporary documents
// to find out changes in the form of Revisions/Track Changes
tempDoc1.Compare(tempDoc2, "Awais", DateTime.Now);
// Save the document containing comparison report
tempDoc1.Save("E:\\Temp\\19.11.docx");
@ awais.hafeez
It helps , thanks a lot