Contents   Index   Previous   Next



For Each

The function For Each can be used to address each element in a selection. This allows you to process all data contained in the selection.

 

 

Example: You want to display the ProductGroup ID and the ProductGroup name in a text element as many times as there are products in the XML source and you don't want to use a table for it:

 

Use the Example.xml file from the tutorial 10_Example_Manual. Create a text element and drag the nodes ProductGroup/ProductGroupID and ProductGroup/Name into it:

 

 

If you generate a layout now, it will only show the first product group and its name:

 

 

Activate the For each property and select the node ProductGroup/Product. A generated layout will now be empty because you need to specify the correct path. As the For each property (that we set to ProductGroup/Product) means that this is our current position in the XML tree, you need to move one step up to address the nodes ProductGroup/ProductGroupID and ProductGroup/Name located in the parent node ProductGroup.

 

To move up in the XML tree, you need to replace the node ProductGroup with two dots, like this: "../ProductGroupID" and "../Name".

 

 

The generated output will now show this:

 

 

Please note: Make sure the text element is big enough, as it will not be sized to the content, other than tables.