Skip to content

Instantly share code, notes, and snippets.

@prichelle
Last active August 29, 2015 14:14
Show Gist options
  • Save prichelle/80978fe4103fadb9f310 to your computer and use it in GitHub Desktop.
Save prichelle/80978fe4103fadb9f310 to your computer and use it in GitHub Desktop.
inline XML parsing from BLOB using ESQL
-- input of this sample is a XML message <XmlCollection><Collection>3c586d6c436f6c6c65637</Collection></XmlCollection>
-- Collection is a XML data in hexadecimal (BLOB) representation
--Create an element of type parser
CREATE LASTCHILD OF OutputRoot DOMAIN 'XMLNSC' NAME 'XMLNSC';
-- Create the root tag element of your output XML
CREATE LASTCHILD OF OutputRoot.XMLNSC NAME 'RootTag';
DECLARE ptrCollection REFERENCE TO InputRoot.XMLNSC.XmlCollection.Collection;
WHILE LASTMOVE(ptrCollection) DO
--Parse the BLOB into XML using the PARSE function
CREATE LASTCHILD OF OutputRoot.XMLNSC.RootTag.RecSec PARSE(CAST(ptrCollection AS BLOB) OPTIONS FolderBitStream CCSID 1208 FORMAT 'XMLNSC');
MOVE ptrCollection NEXTSIBLING;
END WHILE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment