Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

GlideXMLUtil - Scoped, Global

The GlideXMLUtil API provides methods to remove invalid characters from an XML string and to validate an XML string.

Access these methods using the static object GlideXMLUtil. This class is available in scoped and global scripts.

Parent Topic:Server API reference

GlideXMLUtil - removeInvalidChars(String xmlString)

Removes invalid characters from an XML string.

NameTypeDescription
xmlStringStringThe string to be processed.
TypeDescription
StringA string with invalid characters removed.
var test = "test\btab";
var removedTest = GlideXMLUtil.removeInvalidChars(test);

gs.info(removedTest);

Output: testtab

GlideXMLUtil - validateXML(String xmlString, Boolean nsAware, Boolean forgiveUnclosed)

Determines if the specified string is valid XML.

NameTypeDescription
xmlStringStringThe string to be validated.
nsAwareBooleanWhen true, the validation is aware of name spaces. When false, the validation ignores name spaces.
forgiveUnclosedBooleanWhen true, the validation does not check for <xml> tags enclosing the string.
TypeDescription
StringReturns null if the string is valid. Returns an error string describing the error if the specified string is not valid.
var s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><unload unload_date=\"2017-11-27 21:56:14\"><incident action=\"INSERT_OR_UPDATE\"><active>true</active></incident></unload>";
var xml = GlideXMLUtil.validateXML(s,false, false);
gs.info(xml);

Output: null