# XmlFormat()

Escapes special XML characters in a string, so that the string is safe to use with XML.

[EncodeForXML()](encodeforxml.md) is the updated version of this function, which uses ESAPI and escapes a wider range of content.

```
XmlFormat( string=string );
```

**Returns:** string

# Arguments

| Argument | Type | Required | Description | Default |
|----------|------|----------|-------------|---------|
| string | string | Yes | A string or a variable that contains one |  |

# Examples

```1
string = "I like peanut butter & jelly.";
dump(XmlFormat(string)); // I like peanut butter &amp; jelly.
```







# Categories

[Formatting](../../categories/formatting.md), [Strings](../../categories/string.md), [XML](../../categories/xml.md)

# See Also

[EncodeForXML()](encodeforxml.md), [EncodeForXMLAttribute()](encodeforxmlattribute.md), [EncodeForXPath()](encodeforxpath.md), [WriteOutput()](writeoutput.md)