The structure of the XML elements is expected to match the structure
of the RPG variable.
XML processing instructions are ignored by XML-INTO.
Processing instructions are in the form
<?targetname data value ?>
- Scalar variable
-
D libname S 10A
/free
XML-INTO libname %XML(xmldoc : option)
| Sample XML for XML-INTO libname |
path option |
| <libname>data</libname> |
|
| <library>data</library> |
'path=library' |
| <info><library>data</library></info> |
'path=info/library' |
- Array element
-
D sites S 25A DIM(3)
/free
XML-INTO sites(n) %XML(xmldoc : option)
| Sample XML for XML-INTO sites |
path option |
| <sites>data</sites> |
blank |
| <custsites>data</custsites> |
'path=custsites' |
| <info><sites>data</sites></info> |
'path=info/sites' |
- Table name
-
D tabname S 10A DIM(5)
/free
XML-INTO tabname %XML(xmldoc : opts)
| Sample XML for XML-INTO tabname |
path option |
| <tabname>data</tabname> |
blank |
| <library>data</library> |
'path=library' |
| <info><library>data</library></info> |
'path=info/library' |
- Simple data structure or multiple-occurrence data structure
-
Note:
The XML data in the examples show line breaks
and indentation for clarity only. The XML data may be formatted in
any convenient way.
Figure 413.
D pgm DS
D name 10A
D lib 10A
OR
Figure 414.
D pgm DS OCCURS(5)
D name 10A
D lib 10A
/free
XML-INTO pgm %XML(xmldoc : option)
| Sample XML for XML-INTO pgm |
path option |
<pgm>
<name>data</name>
<lib>data</lib>
</pgm> |
blank |
<program>
<name>data</name>
<lib>data</lib>
</program> |
'path=program' |
<api>
<program>
<name>data</name>
<lib>data</lib>
</program>
</api> |
'path=api/program' |
Note: The subfield information can
come from XML elements or XML attributes. The following show other
valid ways to specify the XML for the subfields of the data structure.
The designer of the XML document can use either attributes or elements
freely when representing the XML data for a scalar subfield.
<pgm name="data" lib="data"/>
OR
<pgm name="data">
<lib>data</lib>
</pgm>
- Array of scalar type
-
D sites S 25A DIM(3)
/free
XML-INTO sites %XML(xmldoc : option)
| Sample XML for XML-INTO sites |
path option |
<anything>
<sites>data</sites>
<sites>data</sites>
<sites>data</sites>
</anything> |
blank |
<info>
<custsites>data</custsites>
<custsites>data</custsites>
<custsites>data</custsites>
</info> |
'path=info/custsites' |
- Array of data structures
-
D pgm DS DIM(3) QUALIFIED
D name 10A
D lib 10A
/free
XML-INTO pgm %XML(xmldoc : option)
| Sample XML for XML-INTO pgm |
path option |
<anything>
<pgm name="name1" lib="lib1"/>
<pgm><name>name2</name>
<lib>lib2</lib></pgm>
<pgm lib="lib3"><name>name3</pgm>
</anything> |
blank |
<programs>
<pgm name="name1" lib="lib1"/>
<pgm><name>name2</name>
<lib>lib2</lib></pgm>
<pgm lib="lib3"><name>name3</pgm>
</programs> |
'path=programs/pgm' |
Note: The three "pgm" XML elements
have the name and lib information specified in various combinations
of XML elements and XML attributes. The designer of the XML document
can use either attributes or elements freely when representing the
XML data for a scalar subfield.
- Complex data structure
-
D qualname DS QUALIFIED
D name 10A
D lib 10A
D dtaaraInfo DS QUALIFIED
D dtaara LIKEDS(qualname)
D type 10I 0
D value 100a
/free
XML-INTO dtaaraInfo %XML(xmldoc : option)
| Sample XML for XML-INTO dtaaraInfo |
path option |
<dtaarainfo>
<dtaara>
<name>data</name>
<lib>data</lib>
</dtaara>
<type>data</type>
<value>data</value>
</dtaarainfo> |
blank |
<sys>
<obj>
<dta>
<dtaara>
<name>data</name>
<lib>data</lib>
</dtaara>
<type>data</type>
<value>data</value>
</dta>
</obj>
</sys> |
'path=sys/obj/dta' |
- Handler procedure with array of data structures
-
D myCommArea DS
D total 20u 0
D custType DS qualified
D name 50a varying
D id_no 10i 0
D city 20a
D custHdlr PR
D commArea likeds(myCommArea)
D custinfo likeds(custType) dim(5)
D numElems 10u 0 const
/free
XML-INTO %HANDLER(custHdlr : myCommArea) %XML(xmldoc : option)
Note: The path option is
required when %HANDLER is specified.
| Sample XML for XML-INTO %HANDLER(custHdlr:x) |
path option |
<info>
<cust>
<name>data</name>
<id_no>data</id_no>
<city>data</city>
</cust>
<cust>
<name>data</name>
<id_no>data</id_no>
<city>data</city>
</cust>
:
:
<cust>
<name>data</name>
<id_no>data</id_no>
<city>data</city>
</cust>
</info> |
'path=info/cust' |
- Handler procedure with array of scalar types
-
D myCommArea DS
D total 20u 0
D nameHdlr PR
D commArea likeds(myCommArea)
D names 10a dim(5)
D numNames 10u 0 const
/free
XML-INTO %HANDLER(nameHdlr : myCommArea) %XML(xmldoc : option)
Note: The path option is required when
%HANDLER is specified.
| Sample XML for XML-INTO %HANDLER(nameHdlr:x) |
path option |
<info>
<name>data</name>
<name>data</name>
<name>data</name>
<name>data</name>
:
:
<name>data</name>
<name>data</name>
</info> |
'path=info/names' |