<xml:for>
Iterate over xml collection
Iterate over the xml node and use the Xpath expression to get this xml node.
select(required) Get collection of the XPath expression
var(required) Set the variable of each element
status(optional) Set the variable of loop info Symbol describe count loop count index current loop index isFirst current loop is first isLast current loop is last
trim(optional) Whether to retain the output value of the front and back blank characters Property false:yes(default) true:no(Including the newline)
delimiter(optional) delimiter of loop
Get the collection from Xpath in select and set it to var, var is each element of iterate object.
This is a xml file
We transform it to model
(How to transform the xml model, please read: transform xml model)
In the template, we select this model to find the xml model
If the model group is selected, the xml tag need to specify relation
If the model is selected, the xml tag does not need to specify relation
About the usage of xml tag, please read: xml tag
Get the parent node bookstore that need to be iterated, and set it to a new variable.
$bookstore/book, get the collection of all books, set the iterate object each, and output the title value.
Result
Symbol describe count loop count index current loop index isFirst current loop is first isLast current loop is last
Set the status variable s below, and output its loop information. Set the status variable s, and output it info.
Result
Trim is to judge whether to retain the output value of the front and back blank characters, the default false, that is to say, output all characters.
The following 2 output methods, one default trim="false", the other trim="true".
As you can see, the first method outputs as it is, including front and back spaces and newline characters, while the other removes spaces and newline characters.
The separator between the loop output. If a delimiter is specified, the output elements are separated by separator.
Result