---
title: "Conditionals"
description: "If, Else, and Switch statements."
canonical_url: "https://www.zeyos.com/ixml/ixml-guide/syntax-essentials/conditionals"
markdown_url: "https://www.zeyos.com/ai/guide/ixml/ixml-guide/syntax-essentials/conditionals.md"
section: "ixml-guide"
authority: "guide"
language: "en"
source_repository: "zeyos/guide"
source_path: "docs/ixml/04-syntax-essentials/conditionals.md"
source_revision: "cce886a8da98cd124ee3644711085bbdcf1a87ce"
---

# Conditionals

## `if` — Conditional value execution

[Full reference →](https://www.zeyos.com/ixml/ref/if)

The `IF` command is the primary conditional construct in iXML. It evaluates a comparison and executes its content only if the result is true.

### Syntax

```xml
<if value1="$a" func="=" value2="$b">
    <!-- Executed if a == b -->
</if>
```

### Attributes

| Name | Type | Description |
|---|---|---|
| `value1` | string | Left operand. |
| `value2` | string | Right operand. |
| `func` | function | Comparison operator (default `=`). |

### Comparison Operators

| `func` | Description |
|---|---|
| `=` | Equals. |
| `!=` | Not equals. |
| `>` | Greater than. |
| `<` | Less than. |
| `>=` | Greater or equal. |
| `<=` | Less or equal. |
| `~` | Regex match. |
| `!~` | Regex non-match. |

---

## `is` — Conditional type check

[Full reference →](https://www.zeyos.com/ixml/ref/is)

The `IS` command checks the validity, type, or state of a single variable.

### Syntax

```xml
<is var="myVar" type="numeric">
    <!-- Executed if myVar is numeric -->
</is>
```

### Common Types

- `valid` (defined and not null/false)
- `empty` (null, false, empty string, empty array)
- `array`, `string`, `int`, `float`, `bool`
- `numeric`

---

## `switch` — Multi-way branching

[Full reference →](https://www.zeyos.com/ixml/ref/switch) | `case` reference → | `default` reference →

The `SWITCH` command simplifies chains of if-elseif statements comparing a single value against multiple options.

### Syntax

```xml
<switch value="$status">
    <case value="active">Active!</case>
    <case value="pending">Pending...</case>
    <default>Unknown status</default>
</switch>
```
