Partager via


Case Element

The Case element is used inside a Switch statement or FieldSwitch statement to perform a comparison.

Syntax

<Case
  ExpandXML = "TRUE" | "FALSE"
  Value = "Text">
</Case>

Attributes

Name Description
ExpandXML Optional Boolean. TRUE if the rendered content is passed again through the CAML interpreter, which allows CAML to render CAML.
Value Optional Text. The value to check for in a comparison.

Element Relationships

Parent Elements
FieldSwitch, Switch

Remarks

Within a Switch statement, the Case element is often used in conjunction with the Default element. If the criteria set by the Case value proves false, then the default value is implemented.

Example

The following example checks the value of a UserID field and returns "User Zero" if the value is 0 (zero). Otherwise, it sets a default value: "Not User Zero".

<Switch>
  <Expr><UserID/></Expr>
  <Case Value="0">User Zero</Case>
  <Default>Not User Zero</Default>
</Switch>