IFSXML – as the name could suggests – is a toolbox allowing XML files’s creation within IFS… or not.

This is a very simple solution that adds sequential elements without DOM tree construction. It’s not possible to go back to modify or run query with a previously created item. Part-cons, whatever the size of the output document, the solution doesn’t consume resources and offers good performances level even with small or old systems.

In addition to this functional side, this project is also a good reason to play with ILE RPG.

Current version is 1.0.2 (see version history if you started with a previous), It offers following features:

  • Operates from a V5R2 (adaptable in V5R1 for the more adventurous)
  • Provides two output methods : direct to IFS or to your writer for put the flow where you want (to file, CGI, socket, etc.)
  • Can produce many flow simultaneously
  • Specify the names of elements or attributes with 128 characters and 16384 characters for a value.
  • Can produce formatted documents or not.
  • Offers some performance monitoring functions and trace.
  • Offers adjustable cache from 1K to 16MB (64KB by default) and availability to deactivated it.
  • Easy to use, architectured to maximize reuse and mutualization of your code.
  • Provided as source, in Free-form RPG, with samples. You do not depend on me.

IFSXML is available under the terms of licence Creative Commons Attribution 4.0 International. (CC BY).

Your feedback is welcome ! (Cédric Chapuis, without accent, with a dot between first name and name on gmail)


Full specifications available here and good practice here..


IFSXML purposes two output methods : to file or to your writer (call-back).


Sample – A simple XML flow

Sample bellow demonstrate how create a simple XML file directly to IFS.

     d hXml...
     d                 s                   like(m_ifsxml_handle)

     d outFile...
     d                 s           1024a   varying


       outFile = 'T_IFSXML_01-' + %char(%timestamp()) + '.xml';

       // Get a new handle
       hXml = ifsxml_new();

       // Define and test the ouput file
       if not ifsxml_createFile(hXml: outFile);

         // Display the error message on the current joblog

         // Free the handle

         // Close current activation group.


       // Define the root name
       ifsxml_setRootName(hXml: 'ifsxml');

       // Open element (node) and add attribute to it
       ifsxml_openElement(hXml: 'element');
       ifsxml_addAttribute(hXml: 'attribute' : 'Value');

       // Add a simple element
       ifsxml_addElement(hXml: 'simple': 'value');

       // Close last element opened with openElement()

       // Close the document and the file

       // Free the handle

       // Close current activation group.

       *inlr = *on;


The output :

<?xml version="1.0" encoding="UTF-8"?>
  <element attribute="Value">

Sample – Writer implementation for CGI ouput without need IFS file

Source of the T_IFSXML05 sample provided bellow.


Sources and samples are available on two formats :


See how build module or service program.

Samples provided

T_IFSXML01 : Creates a simple XML document.

T_IFSXML02 : A more complex XML creation splited on two functions.

T_IFSXML03 : Output by writer to the joblog.

T_IFSXML04 : Output by writer to a IFS with specific page code.

T_IFSXML05 : Output by writer on CGI context. (tested under CGIDEV2 Apache instance on V6R1 only)


Another open sources projects

2 réflexions au sujet de « IFSXML »

  1. Question. If I have something like this, would I issue an Open Element and then another Open Element and then Add Element. I see your code that it says close previous element when you open another element. That doesn’t seem to make much sense.

    • Hello Alan,

      This pseudocode example in response (WordPress don’t like XML data on comment, can you send me email with your sample ?) :

      addElement(‘element': ‘Child of element_A’);
      addElement(‘element': ‘Child of element_B’);
      addElement(‘element': ‘Child of element_C’);
      closeElement(); // Close « element_C_child_of_B »
      addElement(‘element': ‘Another child of element_B)';
      closeElement(); // Close « element_B_child_of_A »
      addElement(‘element': ‘Another child of element_A’);
      closeElement(); // Close « element_A »


Les commentaires sont fermés.