Page 1 of 1

How can I pass a XML object down with the VXML

Posted: Fri May 30, 2014 7:17 pm
by Rich
I would like to pass down a data object of type XML DOM with the initial VoiceXML. This would be the same data type that is passed back on a <data> web service call.

Rather than fetch the voice XML then turn around and fetch the initial XML data Object I want to pass the initial XML data object down with the voice XML for performance reasons.

If possible I could create the XML DOM in script but I cant figure out what kind of object to create and how to load it either.

Thanks,

Rich

Re: How can I pass a XML object down with the VXML

Posted: Mon Jun 02, 2014 3:04 pm
by support
Hi Rich,

The data tag is generally the preferred route when fetching XML data. So long as the XML file it not unusually large there needn't be any performance concerns. If you are loading predefined values, you could simply add the data values to your script by defining them using <var> tags, or alternatively loading a Javascript object using the <script> tag as such:

Code: Select all

<?xml version="1.0"?>
<vxml version="2.1">
  <form>
    <script>
      var users = new Array();
      users[0] = new Object();
      users[0].name = 'John Hughes';
      users[0].age = 36;
      users[1] = new Object();
      users[1].name = 'John Smith';
      users[1].age = 25;
    </script>
    <block>
      <prompt>
        Hello, <value expr="users[0].name"/>.
      </prompt>
  </block>
  </form>
</vxml>
We were wondering if you could give an example of your use case for loading the XML data at the beginning of your script so that we could potentially provide some additional insight into how to achieve your goal.

Regards,
Plum Support