
D loc DS DIM(2)
D city 20A VARYING
D prov 2A
D arr S 5I 0 DIM(3)
D xmlDoc S 1000A VARYING
xmlDoc = '<outer>'
+ '<arr>3</arr>'
+ '<arr>4</arr>'
+ '<arr>-2</arr>'
+ '</outer> ;
xml-into arr %XML(xmlDoc);
// arr(1) = 3
// arr(2) = 4
// arr(3) = -2
<locations>
<loc><city>Saskatoon</city><prov>SK</prov></loc>
<loc><city>Regina</city><prov>SK</prov></loc>
</locations>
The target of the XML-INTO operation is an array of data structures. The XML document contains repeated XML elements with the name loc, within a container XML element locations. The name of the RPG data structure array is loc so the path option is not required. The name of the outermost XML element is not considered.
xml-into loc %XML('myarray.xml' : 'doc=file');
// loc(1).city = 'Saskatoon' loc(2).city = 'Regina'
// loc(1).prov = 'SK' loc(2).prov = 'SK'
<data>
<where><city>Edmonton</city><prov>AB</prov></where>
<where><city>Toronto</city><prov>ON</prov></where>
</data>
The example is similar to the previous one,
but the name of the RPG data structure loc is different from
the name of the repeating XML elements where. The path option
must be specified as path=data/where with the name of the
container XML element data and the name of the repeating
XML elements where.
xmlfile = 'mydata.xml';
xml-into loc %XML(xmlfile : 'path=data/where doc=file');
// loc(1).city = 'Edmonton' loc(2).city = 'Toronto'
// loc(1).prov = 'AB' loc(2).prov = 'ON'
