< foreach >

Iterates through an ECMAScript array of items. New in VoiceXML 2.1.

array = "ECMAScript_Expression"
item = "variable"
arrayAn ECMAScript expression that evaluates to an array. Required.
itemThe variable that stores each array item upon each iteration of the loop. Required.
<block>, <catch>, <error>, <filled>, <foreach>, <help>, <if>, <noinput>, <nomatch>, <prompt>
<assign>, <audio>, <break>, <clear>, <data>, <disconnect>, <enumerate>, <exit>, <foreach>, <goto>, <if>, <log>, <prompt>, <reprompt>, <return>, <script>, <submit>, <throw>, <value>, <var>
<?xml version="1.0"?>
<vxml version="2.1"
   <form id="play_fruit">
         <!-- create an array of fruit names -->
         <var name="aFruit" expr="new Array('apples', 'oranges', 'pears', 'bananas')"/>

         Here's a list of fruit we have available today

         <!-- iterate throught through each item in the array -->
         <foreach item="fruit" array="aFruit">
            <value expr="fruit"/>
  • developer_guide/voicexml_references/elements/foreach.txt
  • Last modified: 2015/10/27 12:36
  • by borja