Skip to main content
August 27, 2021
Question

Nested loops inside the DOCX template with XML as data source

  • August 27, 2021
  • 2 replies
  • 0 views

What's the best practice for this use case?

I have XML with the data similar to this:


   
      
      
      
   
   
      
      
      
   
   
      
      
      
   

In DOCX document i would like to achieve this:

So, how can I configure my template to loop inside the loop?

I believe it would be something like this:

But I'm missing this code for looping inside each employee tag.

2 replies

gayathris111098
August 27, 2021

Try like #list doc.employeeData.salary in the first cell. Lets see how its work.

acaciob0002
August 30, 2021

Hi [mention:c127f33e9a884d85a5b139cde70a4674:e9ed411860ed4f2ba0265705b8793d05],

Working with complex structure XML (Multi level), in freemarker can be trick but you can apply some workarounds.

To implement your scenario I changed a little bit your input XML as well as your template. Please see the format that I used in my implementation: 


	
		

The template was configured like this:

The result document is:

Hope that helps

Acacio B.