Hi,
Is there a way for aspose word to understand nested foreach loop.and how to create the nested foreach block in a word template.
I have a class model that has nested structure, I am not able to get expected output, pls let me know if my word template is not correct. which it is showing below
public class country
{
public string countryName{get;set;}
public int countryID{get;set;}
List states{get;set;}
}
public class state
{
public string stateName{get;set;}
public int stateID{get;set;}
List cities{get;set;}
}
public class city
{
public string cityName{get;set;}
public int cityID{get;set;}
public long cityPopulation{get;set;}
}
Word Template
{{TableStart:country}}
CountryName:{{countryName}}
CountryID:{{countryID}}
{{#foreach state}}
StateName:{{stateName}}
StateID{{stateID}}
{{#foreach city}}
CityName:{{cityName}}
CityID:{{cityID}}
CityPopulation{{cityPopulation}}
{{/foreach city}}
{{/foreach state}}
{{TableEnd:country}}
expected output
CountryName: USA
CountryID:1
StateName:Connecticut
StateID:1
CityName:New Haven
CityID:1
CityPopulation:200000
CityName:BridgePort
CityID:2
CityPopulation:…
CityName:…
CityID:…
CityPopulation:…
StateName:Ohio
StateID:2
CityName:columbus
CityID:1
CityPopulation:200000
CityName:…
CityID:…
CityPopulation:…