Sign in

docs RPG Reference

Examples of the trim option

Examples of the trim option

The following definition is used in the examples

D data            S            100A    VARYING

Assume that file data.xml contains the following lines:

<text>
    line1
    line2
</text>

Here is another view of this same file where

’_’ : represents a blank

‘T’ : represents a tab

‘F’ : represents a line-feed

<text>____F
Tline1F
____line2F
</text>F
  1. The default of trim=all is used. Leading and trailing whitespace is removed. Strings of internal whitespace are changed to a single blank.

      xml-into data %XML('data.xml' : 'doc=file');
      // data = 'line1 line2'
  2. Option trim=none is specified. No whitespace is trimmed from text data. Two views of the resulting value are shown.

    1. The line-feed and tab characters are shown as ’?’.

    2. The blanks, line-feed, and tab characters are shown in the same way as in the second view of the document above where

      ’_’ : represents a blank

      ‘T’ : represents a tab

      ‘F’ : represents a line-feed

      xml-into data %XML('data.xml' : 'doc=file trim=none');
      // data = '    ??line1?    line2?'
      // data = '____FTline1F____line2F'