Using the <eXpat/> XML Parser on System i:

I'm working on putting together information on how to use the open source eXpat XML parser on the System i, I'm using this parser from the HTTPAPI project to parse XML responses.

Since I've done the work of making it compile and run on the System i, it seems only natural to provide it for other people to use in their projects.


For documenation on how to use Expat from your ILE C programs, please take a look at the Expat home page. In particular, there's a link to an introductory article by Clark Cooper that's a little dated, but very helpful in getting started.

For documentation on how to use Expat from your ILE RPG programs, please read the following articles that I've written for the System iNetwork:
Using Expat from an RPG Program, Part 1
Using Expat from an RPG Program, Part 2
Using Expat from an RPG Program, Part 3
Using Expat from an RPG Program, Part 4

The preceding articles are based on the older (UTF-8 build) of Expat for System i. The following article describes the newer (UTF-16 build):
New Version of Expat with UTF-16 Support


My System i port of Expat contains all of the source code, plus a pre-compiled service program called "EXPAT." This way, you can use Expat on your system, even if you do not have the ILE C compiler installed.

Starting with version 2.0.0, I have Expat compiled with the XML_UNICODE symbol defined. This tells Expat to output UTF-16 when calling your procedures. This is a good thing for RPG programmers because RPG supports UTF-16 natively. (You code it as UCS2, then tell it to use CCSID(1200) which is UTF-16.)

Download Version 2.0.0 (Requires V5R1): Version 2.0.0 (SAVF format)

Download Version 2.0.0 (Requires V5R1): Version 2.0.0 (XML installer format -- source only)


The old version, 1.95.8, is still available. It's compiled to output UTF-8 (which is the default) and you may still need to use it if you have programs that are written to interpret UTF-8. I'll keep it online for awhile until people have had a chance to update their code to use UTF-16 instead.

Download Version 1.95.8 (Requires V5R1): Version 1.95.8 (SAVF format)

Download Version 1.95.8 (Requires V5R1): Version 1.95.8 (XML installer format -- source only)


 
How to download & install:

  1. Download the save file (from the link above) to your PC

  2. Use FTP to copy the save file to your System i. Use the following steps:
    • Open a Command Prompt (MS-DOS Prompt)
    • Type: ftp your-iseries-name-here
    • Type: (enter your userid & password)
    • Type: binary
    • Type: quote site namefmt 1
    • Type: put expat-0.95.8.savf /qsys.lib/qgpl.lib/libexpat.savf
    • Type: quit

  3. You should now have a save file on your system called QGPL/LIBEXPAT. If you want to make sure it's there, you can type: DSPSAVF QGPL/LIBEXPAT

  4. If you already have a LIBEXPAT library, you might want to delete it to get rid of any previous versions. I cannot be held responsible if you lose anything important. Please make sure that nothing important is in this library before deleting anything. DLTLIB LIB(LIBEXPAT)

  5. Restore the library from the save file:
    RSTLIB SAVLIB(LIBEXPAT) dev(*SAVF) SAVF(QGPL/LIBEXPAT)

  6. If all is well, you can delete the save file: DLTF QGPL/LIBEXPAT

  7. If you want to use this with HTTPAPI, please follow these steps:

    WARNING: HTTPAPI 1.16 and earlier require a UTF-8 version of Expat. HTTPAPI 1.17 and later require a UTF-16 version of Expat.

    • First, download HTTPAPI's LIBHTTP library. Instructions are on the HTTPAPI Web Page
    • CRTDUPOBJ OBJ(EXPAT) FROMLIB(LIBEXPAT) OBJTYPE(*SRVPGM) TOLIB(LIBHTTP)
    • CHGCURLIB CURLIB(LIBHTTP)
    • CRTCLPGM INSTALL SRCFILE(LIBHTTP/QCLSRC)
    • CALL INSTALL
    • When it asks if you'd like to build Expat from source code, choose 'N' because it's already been compiled.
    • When it asks if you're like to compile support for Expat into HTTPAPI, choose 'Y'