D etudiant ds qualified
D age 3p 0
D nom 25a varying
D ecole 50a varying
D student ds likeds(etudiant)
<Étudiant Nom="Élise" Âge="12">
<École>Collège Saint-Merri</École>
</Étudiant>
The path option is not necessary, because the default path is the name of the RPG variable ETUDIANT, which matches the converted form of the actual XML name, Étudiant.
xml-into etudiant %xml('info.xml'
: 'doc=file case=convert '
+ 'ccsid=ucs2');
// etudiant.nom = 'Élise'
// etudiant.age = 12
// etudiant.ecole = 'Collège Saint-Merri'
xml-into student %xml('info.xml'
: 'doc=file case=convert '
+ 'ccsid=ucs2 path=etudiant');
// student.nom = 'Élise'
// student.age = 12
// student.ecole = 'Collège Saint-Merri'
D employee_info ds qualified
D last_name 25a varying
D first_name 25a varying
D is_manager 1a
D emp ds likeds(employee_info)
<employee-info is-manager="y">
<last-name>Smith</last-name>
<first-name>John</first-name>
</employee-info>
The RPG data structure name employee_info matches the converted form, EMPLOYEE_INFO, of the XML name employee-info, so the path option is not required.
xml-into employee_info %xml('data.xml'
: 'doc=file case=convert ');
// employee_info.last_name = 'Smith'
// employee_info.first_name = 'John'
// employee_info.is_manager = 'y'
xml-into emp %xml('data.xml'
: 'doc=file case=convert '
+ 'ccsid=ucs2 path=employee_info' );
// emp.last_name = 'Smith'
// emp.first_name = 'John'
// emp.is_manager = 'y'
D employee_info_ ds qualified
D last_name_ 25a varying
D first_name_ 25a varying
D is_manager_ 1a
<employee_info_DBCS is_manager_DBCS="y">
<last_name_DBCS>Smith</last_name_DBCS>
<first_name_DBCS>John</first_name_DBCS>
</employee_info_DBCS>
Option case=convert is specified. After any conversion of the alphabetic characters using the *LANGIDSHR table for the job, the next step converts any remaining characters that are not A-Z or 0-9 to the underscore character, including DBCS data and the associated shift-out and shift-in characters. After this step, the XML name last_name_DBCS would be converted to LAST_NAME_____. The next step merges any remaining underscores, including any underscores that appeared in the original name, to a single underscore. The resulting name is LAST_NAME_.
xml-into employee_info_ %xml('data.xml'
: 'doc=file case=convert '
+ 'ccsid=ucs2');
// employee_info_.last_name_ = 'Smith'
// employee_info_.first_name_ = 'John'
// employee_info_.is_manager_ = 'y'
D employee_info ds qualified
D last_name 25a varying
D first_name 25a varying
D is_manager 1a
<DBCS_employee_info DBCS_is_manager="y">
<DBCS_last_name>Smith</DBCS_last_name>
<DBCS_first_name>John</DBCS_first_name>
</DBCS_employee_info>
Option case=convert is specified. After the conversion of the non-alphanumeric characters to a single underscore, the name DBCS_last_name is converted to _LAST_NAME. Since RPG does not support names starting with an underscore, the initial underscore is removed. The final converted name is LAST_NAME.
xml-into employee_info %xml('data.xml'
: 'doc=file case=convert '
+ 'ccsid=ucs2');
// employee_info.last_name = 'Smith'
// employee_info.first_name = 'John'
// employee_info.is_manager = 'y'
