<foreach>
<foreach>
The <foreach>
element allows a VoiceXML application to iterate through an ECMAScript array and to execute the content contained within the <foreach>
element for each item in the array.
Attributes
Name | Data type | Description |
---|---|---|
array | String | An ECMAScript expression that must evaluate to an array; otherwise, an error.semantic event is thrown. |
item | String | The variable that stores each array item upon each iteration of the loop. A new variable will be declared if it is not already defined within the parent's scope. |
Notes
Both “array” and “item” must be specified. Please refer to the VoiceXML 2.1 Draft for examples and detailed usage information for this tag.
Example
The output of the above script would be:
Computer: Please select one of the following movies. Computer: The Godfather, High Fidelity, Raiders of The Lost Ark. Human: High Fidelity. Computer: You said High Fidelity.
Child Tags
<audio>, <assign>, <break>, <clear>, <data>, <disconnect>, <emphasis>, <enumerate>, <exit>, <foreach>, <goto>, <if>, <log>, <metadata>, <mark>, <paragraph>, <phoneme>, <prompt>, <prosody>, <reprompt>, <return>, <say-as>, <sentence>, <script>, <speak>, <sub>, <submit>, <throw>, <value>, <var>, <voice>
Parent Tags
<block>, <catch>, <error>, <filled>, <foreach>, <help>, <if>, <noinput>, <nomatch>, <prompt>
Last updated