api:first
Version 23.0.9145
Version 23.0.9145
api:first
Use the api:first
keyword to execute a section of a script for only the first iteration of an api:call or api:enum keyword. It is a convenient way to generate headings or to inspect the first item of a feed before going through the rest of the feed.
During the first iteration, the api:first
body executes before any other code in the api:call
or api:enum
, regardless of where api:first
is located in the call or enum body. Therefore, CData recommends you place the api:first
at the top of the api:call
or api:enum
body.
If the scope has no items, neither api:first
nor api:last is executed.
Parameters
None
Control Attributes
None
Example
Create an HTML table from a feed where each item is represented as a row:
<api:call op="listCustomers">
<api:first>
<table>
<thead>
<api:enum item="customer">
<td>[_attr]</td>
</api:enum>
</thead>
</api:first>
<tr>
<api:enum item="customer">
<td>[_value]</td>
</api:enum>
</tr>
<api:last>
</table>
</api:last>
</api:call>
See Also
- api:last: Execute a code block only for the last iteration.