Create a Word Document with One XML Recipe per Page
Question details
Create a Word document from updated XML recipe records, with each recipe and its ingredients on a separate page.

- Product
- Microsoft Word and Microsoft Excel
- Device & OS
- not provided
- Scenario
- Multiple users continually update an XML source containing recipes and nested ingredient collections.
- Observed behavior
- The desired document contains one recipe per page, including its recipe fields and ingredient list.
Check the XML structure to identify the recipe record, its fields, and the nested ingredient elements. Decide whether each ingredient list can be combined into one field or whether you need a custom document-generation process.
Use Excel and Word Mail Merge for Flattened Recipe Records
Use this method when the XML can be converted into one spreadsheet row per recipe.
In Excel, use Data > Get Data > From File > From XML, if available, and select the recipe XML file.
In the import or query editor, arrange the data so each recipe has one row and each recipe field has a column. Combine its ingredients into a single text field before loading the table into a worksheet.
Save the worksheet as an Excel workbook. When the XML changes, refresh the query from Excel's Data tab and save the workbook again before merging.
In Word, choose Mailings > Start Mail Merge > Letters. Select Mailings > Select Recipients > Use an Existing List, open the workbook, and choose the worksheet containing the recipe table.
Type the recipe layout in Word and use Mailings > Insert Merge Field to add the recipe fields and combined ingredient list. Choose Preview Results, then Finish & Merge > Edit Individual Documents to generate the document.

Transform Nested XML with XSLT or Generate Word Files with Code
Use a custom transformation or program when recipes have variable-length ingredient collections that are difficult to flatten.
Review Recipe Documents with WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for opening and editing Word documents and Excel workbooks. It supports a straightforward move to WPS, although it does not replace the custom XML transformation described above.

Frequently Asked Questions
Can Word mail merge directly repeat nested ingredients for each recipe?
A standard mail merge works best with one flat row per recipe. Combine the ingredients into a field in Excel, or use a custom transformation or program to handle a variable-length ingredient collection.
How do I include new XML changes in the merged document?
Refresh the imported XML data from Excel's Data tab, save the workbook, and run Finish & Merge again in Word. An existing merged document does not automatically update when the XML changes.
Why does a recipe take up more than one page?
Starting each record on a new page does not guarantee that its content fits on one page. Use Preview Results in Word and adjust the font, margins, spacing, or recipe content if a record overflows.
When should I use the Open XML SDK instead of mail merge?
Consider the Open XML SDK when you need code to generate DOCX files with variable-length ingredient lists, custom tables, or controlled page breaks. For fixed fields that fit into one row per recipe, Word mail merge is usually simpler.




