× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



The original article on generating XML from RPG using CGIDEV2 is here: http://www.ibmsystemsmag.com/ibmi/developer/rpg/Using-CGIDEV2-for-Generating-XML/

We also mentioned some different approaches based on new tooling towards the bottom of this page: http://www.ibmsystemsmag.com/ibmi/developer/rpg/open_source_rpg_apps/?page=2

This is a simple example of the powerExt approach:

xmlNode( 'rootElement' );
xmlNode( 'Element1': '': elementValue1 );
xmlNode( 'Element2' );
xmlNode( 'Child1': '': childValue1 );
xmlNode( 'Child2': '': childValue2 );
xmlEndNode();
xmlEndNode();

echoToStmf( '/inetworktread.xml': 1208 );

And this is a similar example using XMLi:

// Tell xmli you want to build xml in a variable.
xmli_useVariable(char1024);
xmli_setFormat(XML_FORMAT_SIMPLE);

// Build some XML
xmli_openTag( 'rootElement' );
xmli_addElement( 'Element1' : elementValue1 );
xmli_addElement( 'Element2' );
xmli_addElement('Child1' : childValue1 );
xmli_addElement('Child2' : childValue2 );
xmli_closeTag( 'Element2' );
xmli_closeTag( 'rootElement' );

// XML is now in the char1024 variable...

// Tell XMLi you're done building XML and don't need the variable linked anymore...
xmli_freeVariable(char1024);

// Now write the data to a file in the IFS...
xmli_writeToFileWithVar( '/Examples/Results/XMLiTest.xml'
: char1024 : XML_ENCODING_UTF8);


XMLi can also use a rather sophisticated version of the CGIDEV2 template approach where the template can even include SQL statements.


Jon Paris

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.