/// <summary> /// Generates the document using sample generic doc generator using XML. /// </summary> private static void GenerateDocumentUsingSampleGenericDocGeneratorUsingXml() { // Test document generation from template("Test_Template - 1.docx") string dataAsXml = "<field>" + "<listFields>" + "<field orderName=\"Test Order\" orderDescription=\"Test Order Description\" id=\"\" contentControlTagREFS=\"PlaceholderNonRecursiveC PlaceholderNonRecursiveD\"/>" + "<field id=\"736d79d9-0689-419e-b27a-1867f613fd80\" contentControlTagREFS=\"PlaceholderContainerA\">" + "<listFields>" + "<field id=\"736d79d9-0689-419e-b17a-1867f613fd80\" contentControlTagREFS=\"PlaceholderRecursiveA\">" + "<listFields>" + "<field vendorName=\"Vendor 1\" id=\"736d79d9-1689-419e-c27a-1867f613fd80\" contentControlTagREFS=\"PlaceholderNonRecursiveA\"/>" + "<field vendorName=\"Vendor 2\" id=\"736d79d9-0589-419e-c27a-1867f613fd80\" contentControlTagREFS=\"PlaceholderNonRecursiveA\"/>" + "</listFields>" + "</field>" + "<field id=\"736d79d9-0689-119e-b27a-1867f613fd80\" contentControlTagREFS=\"PlaceholderRecursiveB\">" + "<listFields>" + "<field itemName=\"Item 1\" id=\"736d79d9-0689-419e-c27a-1867f613fd80\" contentControlTagREFS=\"PlaceholderNonRecursiveB\" />" + "<field itemName=\"Item 2\" id=\"736d79d9-0689-419e-b27a-1867f613dd80\" contentControlTagREFS=\"PlaceholderNonRecursiveB\" />" + "</listFields>" + "</field>" + "</listFields>" + "</field>" + "</listFields>" + "<contentControls>" + "<contentControl type=\"2\" tag=\"PlaceholderNonRecursiveC\" refControlValue=\"orderName\" refTagValue=\"id\"/>" + "<contentControl type=\"2\" tag=\"PlaceholderNonRecursiveD\" refControlValue=\"orderDescription\" refTagValue=\"id\"/>" + "<contentControl type=\"4\" tag=\"PlaceholderContainerA\" refTagValue=\"id\"/>" + "<contentControl type=\"1\" tag=\"PlaceholderRecursiveA\" refTagValue=\"id\"/>" + "<contentControl type=\"1\" tag=\"PlaceholderRecursiveB\" refTagValue=\"id\"/>" + "<contentControl type=\"2\" tag=\"PlaceholderNonRecursiveA\" refControlValue=\"vendorName\" refTagValue=\"id\"/>" + "<contentControl type=\"2\" tag=\"PlaceholderNonRecursiveB\" refControlValue=\"itemName\" refTagValue=\"id\"/>" + "</contentControls>" + "</field>"; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(dataAsXml); DocumentGenerationInfo generationInfo = GetDocumentGenerationInfo("SampleGenericDocumentGeneratorUsingXml", "1.0", xmlDoc.DocumentElement, "Test_Template - 1.docx", false); SampleGenericDocumentGeneratorUsingXml sampleGenericDocumentGeneratorUsingXml = new SampleGenericDocumentGeneratorUsingXml(generationInfo); byte[] result = sampleGenericDocumentGeneratorUsingXml.GenerateDocument(); WriteOutputToFile("SampleGenericDocumentGeneratorUsingXml1.docx", "Test_Template - 1.docx", result); // Test document generation from template("Test_Template - 2.docx") dataAsXml = "<field>" + "<listFields>" + "<field orderName=\"Test Order\" orderDescription=\"Test Order Description\" id=\"\" contentControlTagREFS=\"PlaceholderNonRecursiveC PlaceholderNonRecursiveD\"/>" + "<field id=\"736d79d9-0689-419e-b27a-1867f613fd80\" contentControlTagREFS=\"PlaceholderContainerA\">" + "<listFields>" + "<field id=\"736d79d9-0689-419e-b17a-1867f613fd80\" contentControlTagREFS=\"PlaceholderRecursiveA VendorDetailRow\">" + "<listFields>" + "<field vendorName=\"Vendor 1\" id=\"736d79d9-1689-419e-c87a-1867f613fd80\" contentControlTagREFS=\"PlaceholderNonRecursiveA VendorId VendorName\"/>" + "<field vendorName=\"Vendor 2\" id=\"736d79d9-0589-419e-c77a-1867f613fd80\" contentControlTagREFS=\"PlaceholderNonRecursiveA VendorId VendorName\"/>" + "<field vendorName=\"Vendor 3\" id=\"736d79d9-0589-419e-c67a-1867f613fd80\" contentControlTagREFS=\"PlaceholderNonRecursiveA VendorId VendorName\"/>" + "<field vendorName=\"Vendor 4\" id=\"736d79d9-0589-419e-c57a-1867f613fd80\" contentControlTagREFS=\"PlaceholderNonRecursiveA VendorId VendorName\"/>" + "<field vendorName=\"Vendor 5\" id=\"736d79d9-0589-419e-c47a-1867f613fd80\" contentControlTagREFS=\"PlaceholderNonRecursiveA VendorId VendorName\"/>" + "<field vendorName=\"Vendor 6\" id=\"736d79d9-0589-419e-c37a-1867f613fd80\" contentControlTagREFS=\"PlaceholderNonRecursiveA VendorId VendorName\"/>" + "<field vendorName=\"Vendor 7\" id=\"736d79d9-0589-419e-c27a-1867f613fd80\" contentControlTagREFS=\"PlaceholderNonRecursiveA VendorId VendorName\"/>" + "<field vendorName=\"Vendor 8\" id=\"736d79d9-0589-419e-c17a-1867f613fd80\" contentControlTagREFS=\"PlaceholderNonRecursiveA VendorId VendorName\"/>" + "</listFields>" + "</field>" + "<field id=\"736d79d9-0689-119e-b27a-1867f613fd80\" contentControlTagREFS=\"PlaceholderRecursiveB\">" + "<listFields>" + "<field itemName=\"Item 1\" id=\"736d79d9-0689-419e-c27a-1867f613fd80\" contentControlTagREFS=\"PlaceholderNonRecursiveB\" />" + "<field itemName=\"Item 2\" id=\"736d79d9-0689-419e-b27a-1867f613dd80\" contentControlTagREFS=\"PlaceholderNonRecursiveB\" />" + "<field itemName=\"Item 3\" id=\"736d79d9-0689-419e-b12a-1867f613dd80\" contentControlTagREFS=\"PlaceholderNonRecursiveB\" />" + "<field itemName=\"Item 4\" id=\"736d79d9-0689-419e-b22a-1867f613dd80\" contentControlTagREFS=\"PlaceholderNonRecursiveB\" />" + "<field itemName=\"Item 5\" id=\"736d79d9-0689-419e-b43a-1867f613dd80\" contentControlTagREFS=\"PlaceholderNonRecursiveB\" />" + "<field itemName=\"Item 6\" id=\"736d79d9-0689-419e-b87a-1867f613dd80\" contentControlTagREFS=\"PlaceholderNonRecursiveB\" />" + "<field itemName=\"Item 7\" id=\"736d79d9-0689-419e-b98a-1867f613dd80\" contentControlTagREFS=\"PlaceholderNonRecursiveB\" />" + "<field itemName=\"Item 8\" id=\"736d79d9-0689-419e-b19a-1867f613dd80\" contentControlTagREFS=\"PlaceholderNonRecursiveB\" />" + "</listFields>" + "</field>" + "</listFields>" + "</field>" + "</listFields>" + "<contentControls>" + "<contentControl type=\"2\" tag=\"PlaceholderNonRecursiveC\" refControlValue=\"orderName\" refTagValue=\"id\"/>" + "<contentControl type=\"2\" tag=\"PlaceholderNonRecursiveD\" refControlValue=\"orderDescription\" refTagValue=\"id\"/>" + "<contentControl type=\"4\" tag=\"PlaceholderContainerA\" refTagValue=\"id\"/>" + "<contentControl type=\"1\" tag=\"PlaceholderRecursiveA\" refTagValue=\"id\"/>" + "<contentControl type=\"1\" tag=\"PlaceholderRecursiveB\" refTagValue=\"id\"/>" + "<contentControl type=\"2\" tag=\"PlaceholderNonRecursiveA\" refControlValue=\"vendorName\" refTagValue=\"id\"/>" + "<contentControl type=\"2\" tag=\"PlaceholderNonRecursiveB\" refControlValue=\"itemName\" refTagValue=\"id\"/>" + "<contentControl type=\"1\" tag=\"VendorDetailRow\" refTagValue=\"id\"/>" + "<contentControl type=\"2\" tag=\"VendorId\" refControlValue=\"id\" refTagValue=\"id\"/>" + "<contentControl type=\"2\" tag=\"VendorName\" refControlValue=\"vendorName\" refTagValue=\"id\"/>" + "</contentControls>" + "</field>"; xmlDoc = new XmlDocument(); xmlDoc.LoadXml(dataAsXml); generationInfo = GetDocumentGenerationInfo("SampleGenericDocumentGeneratorUsingXml", "2.0", xmlDoc.DocumentElement, "Test_Template - 2.docx", false); sampleGenericDocumentGeneratorUsingXml = new SampleGenericDocumentGeneratorUsingXml(generationInfo); result = sampleGenericDocumentGeneratorUsingXml.GenerateDocument(); WriteOutputToFile("SampleGenericDocumentGeneratorUsingXml2.docx", "Test_Template - 2.docx", result); }