Sign in

docs RPG Reference

Examples of the case option with values upper, lower and any

Examples of the case option with values upper, lower and any

The following definitions are used in the examples

D info            DS                   QUALIFIED
D   name                        10A
D   id_no                        5A
D xmlDoc          S           1000A    VARYING
  1. The XML document uses lowercase for element names and attributes. The case option defaults to lowercase so it is not needed.

      xmlDoc = '<info><name>Jim</name><id_no>103</id_no></info>';
      xml-into info %XML(xmlDoc);
      // info.name = 'Jim       '
      // info.id_no = '103'
  2. The XML document uses uppercase for element names and attributes. Option case=upper must be specified.

      xmlDoc = '<INFO><NAME>Bill</NAME><ID_NO>104</ID_NO></INFO>';
      xml-into info %XML(xmlDoc : 'case=upper');
      // info.name = 'Bill      '
      // info.id_no = '104'
  3. The XML document uses mixed case for element names and attributes. Option case=any must be specified.

      xmlDoc = '<INFO><name>Tom</name>'
                  + '<ID_NO>105</ID_NO></INFO>';
      xml-into info %XML(xmlDoc : 'case=any');
      // info.name = 'Tom       '
      // info.id_no = '104'
  4. The XML document uses mixed case for element names and attributes but the case option is not specified. The XML-INTO operation fails with status 00353 because it assumes that the XML elements will have lowercase names.

      xmlDoc = '<INFO><name>Tom</name>'
                  + '<ID_NO>105</ID_NO></INFO>';
      xml-into(e) info %XML(xmlDoc);
      // %error = *on
      // %status = 353