Setting Environment Attributes for XML in ECMAScript

When you are using ECMAScript to handle XML, you can tailor how the parser renders your output. In particular, there are three global attributes you may be interested in setting. To set these, simply type or paste them in at the top of your JSX file with the values you want.

# Global Environment Attributes

prettyIndent — Specifies the number of spaces each child of your XML will be indented when printed to the console.

Usage: XML.environment.@prettyIndent = 2;

prettyPrint — Specifies whether the your XML should be arranged with indents and line breaks when printed to the console.

Usage: XML.environment.@prettyPrint = true;

whitespace — Specifies whether whitespace characters should be removed from the beginning or end of any textnode. Whitespace is defined as:

- '\t' \u0009 HORIZONTAL TABULATION

- '\n' \u000A NEW LINE

- '\f' \u000C FORM FEED

- '\r' \u000D CARRIAGE RETURN

- ' ' \u0020 SPACE

- Any character who's ASCII value is less than or equal to 0x20 (including control characters)

Usage: XML.environment.@whitespace = false;

Related Topics

Getting Started with Script for Mapping