I have written programs to do what you want to do, and would be happy to provide an example, for you and anyone else who is interested.
You can get me at firstname.lastname@example.org
DB2 SQL has the capability of creating XML …
XMLATTRIBUTES (DEPT AS “NAME” ),
XMLELEMENT(NAME “FIRSTNAME”, FNM),
XMLELEMENT(NAME “LASTNAME”, LNM) )
ORDER BY LNM )
) ) AS “DEPT_LIST”
GROUP BY DEPT;
<DEPARTMENT NAME=”BADM “><EMP><FIRSTNAME>CHERYL </FIRSTNAME><LASTNAME>ST……
Er… I do not know who wrote the piece above, regarding SQL generating XML. It was not me. I do have the feeling that it is not available in OS version 5 or below. Probably 6.1.
I can highly recommend the program from Sloopy. Its very well written and works after you made your changes according to your needs.
The portion of the answer above that refers to the XML2CLOB() function is incorrect. The function is from DB2 UDB for LUW. It is not part of DB2 on i nor is it supplied with DB2 XML Extenders for i.
However, DB2 XML Extenders for i can supply a number of functions that can make DB2 and XML easy to work with together.