# <data>

Description

(VoiceXML 2.1 feature) Allows the fetching of, and read-only DOM access to, arbitrary XML data, without transitioning to a new VoiceXML document.

Note: The `<vxml>` `version` attribute must be specified as 2.1 (or higher) to use this feature. If the `version` is specified otherwise, `<data>` will not be recognized and will be treated as an invalid child element.

Syntax

    <data
        name="string"
        src="URI"
        srcexpr="ECMAScript_Expression"
        namelist="variable1 variable2 ..."
        method="get" | "post"
        enctype="MIME_type"
        fetchaudio="URI"
        fetchhint="safe"
        fetchtimeout="time_interval"
        maxage="integer"
        maxstale="integer"/>

Attributes

Attribute | Description
name | The name of the variable that exposes the DOM. For ECMAScript functions to navigate this variable, please see http://www.w3.org/TR/2005/CR-voicexml21-20050613/#sec-data-dom.
src | The URI of the request, to fetch the XML data. Optional. Exactly one of src or srcexpr must be specified.
srcexpr | An ECMAScript expression to be evaluated and used as the URI of the request, to fetch the XML data. Optional. Exactly one of src or srcexpr must be specified.
namelist | A space-separated list of variables to submit with the request. By default, no variables are submitted. Any declared VoiceXML and ECMAScript variables can be referenced. Optional.
method | The request method: get or post. Optional. (Defaults to get.)
enctype | The MIME encoding of the submitted data. The following types are supported: application/x-www-form-urlencoded multipart/form-data Optional. (Defaults to application/x-www-form-urlencoded.)
fetchaudio | The URI of the audio to play while waiting for the XML data to be fetched. Optional.
fetchhint | Defines when the XML data should be fetched. Optional. safe - only load the XML data when needed (Currently, fetchhint="prefetch" is not supported in the `<data>` tag.)
fetchtimeout | The length of time to wait for the XML data to be fetched before throwing an `error.badfetch` event. Optional.
maxage | Indicates that this document is willing to use a cached copy of the XML data only while the age of the cached copy is less than or equal to the number of seconds specified by this attribute. Optional.
maxstale | Indicates that this document is willing to use a cached copy of the XML data that has exceeded its expiration time by as much as the number of seconds specified by this attribute. Optional.

Attribute Notes

- If `srcexpr` cannot be evaluated, an `error.semantic` event is thrown.

Parents

<block>, <catch>, <error>, <filled>, <foreach>, <form>, <help>, <if>, <noinput>, <nomatch>, <vxml>

Children

None.

Extensions

None.

Limitations/Restrictions

- The `<data>` tag does not support `fetchhint="prefetch"`.
- The `fetchaudio` attribute is not supported when `<data>` is used as a child of `<form>` or `<vxml>`.
- `<data>` cannot be used as a child of `<foreach>` when `<foreach>` is a child of `<prompt>`.

Example

    <?xml version="1.0"?>
    <vxml version="2.1" xmlns="http://www.w3.org/2001/vxml">
      <data name="quotedata" src="http://www.quoteserver.com/20040517/f.xml"/>
      <form>
        <block>
          <var name="quote" expr="quotedata.documentElement"/>
          The change for Ford Motor Company is
          <value expr="quote.getElementsByTagName('change').item(0).firstChild.data"/>.
        </block>
      </form>
    </vxml>

The XML data associated with the example above:

    <?xml version="1.0"?>
    <?access-control allow="*"?>
    <quote>
      <ticker>F</ticker>
      <name>Ford Motor Company</name>
      <change>1.00</change>
      <last>30.00</last>
    </quote>