# \<rule>

## \<rule> <a href="#rule" id="rule"></a>

An SRGS+XML rule definition is contained within a `<rule>` block.

### Attributes

<table><thead><tr><th width="123.33333333333331">Name</th><th width="158">Data type<select><option value="76e9e6a0ccc240f28756d5de0fcfbc42" label="String" color="blue"></option><option value="c4f21faa49804e8f825b390ac7911577" label="Integer" color="blue"></option><option value="63593605c5a142359b085b2e73df21c6" label="Boolean" color="blue"></option></select></th><th>Description</th></tr></thead><tbody><tr><td>id</td><td><span data-option="76e9e6a0ccc240f28756d5de0fcfbc42">String</span></td><td>This attribute specifies the rulename for the rule.</td></tr><tr><td>scope</td><td><span data-option="76e9e6a0ccc240f28756d5de0fcfbc42">String</span></td><td>Can be either “public” or “private”.</td></tr></tbody></table>

### Notes

For examples and usage information, please refer to the [Speech Recognition Grammar Specification](http://www.w3.org/TR/2002/CR-speech-grammar-20020626/).

### Example

```markup
<?xml version="1.0"?>
<vxml version="2.0">
  <form>
    <field name="animal">
      <grammar type="application/srgs+xml" root="ROOT" mode="voice">
        <rule id="ROOT">
          <one-of>
            <item>Dog</item>
            <item>Cat</item>
          </one-of>
        </rule>
      </grammar>
      <prompt>
        Say either dog or cat.
      </prompt>
      <filled>
        <prompt>
          You said <value expr="animal"/>. Goodbye.
        </prompt>
        <exit/>
      </filled>
    </field>
  </form>
</vxml>
```

The output of the above script would be:

> Computer: Say either dog or cat.\
> Human: Dog.\
> Computer: You said dog.

### Child Tags

[\<example>](https://docs.plumvoice.com/dev/voicexml/tags/example-tag), [\<item>](https://docs.plumvoice.com/dev/voicexml/tags/item-tag), [\<one-of>](https://docs.plumvoice.com/dev/voicexml/tags/one-of-tag), [\<ruleref>](https://docs.plumvoice.com/dev/voicexml/tags/ruleref-tag), [\<tag>](https://docs.plumvoice.com/dev/voicexml/tags/tag-tag), [\<token>](https://docs.plumvoice.com/dev/voicexml/tags/token-tag)

### Parent Tags

[\<grammar>](https://docs.plumvoice.com/dev/voicexml/tags/grammar-tag)
