Hello,
I understand you want to populate a PL/I structure with the contents of
a XML string. The following example is by Peter Elderon who presented it
at a GUIDE/SHARE some years ago. You only need 3 LIMITED ENTRYS of the
event handler structure. At the end, fill in the name of the structure
you want to populate. The example works exactly in the reverse way as
XMLSTRING.
HTH
Jessica
<cut>
dcl I bin fixed(15);
dcl path char(133) varying init('');
dcl xmlDocument char(32000) init(' ');
eventHandler.e07 = my_start_of_element;
eventHandler.e12 = my_end_of_element;
eventHandler.e15 = my_content_characters;
call plisaxa( eventHandler,
addr(path),
addrdata(xmlDocument),
length(trim(xmlDocument)));
<cut>
my_start_of_element:
proc( userToken, xmlToken, TokenLength )
returns( byvalue fixed bin(31) )
options( byvalue linkage(optlink) );
dcl userToken pointer;
dcl xmlToken pointer;
dcl tokenLength fixed bin(31);
dcl path char(133) varying based(userToken);
dcl chars char(32000) based;
if (length(path) > 0)
then
path !!= '.';
path !!= substr(xmltoken->chars, 1, tokenlength);
return(0);
end;
my_end_of_element:
proc( userToken, xmlToken, TokenLength )
returns( byvalue fixed bin(31) )
options( byvalue linkage(optlink) );
dcl userToken pointer;
dcl xmlToken pointer;
dcl tokenLength fixed bin(31);
dcl path char(133) varying based(userToken);
if (length(path) = tokenlength)
then
path = substr(path, 1, length(path) - tokenlength);
else
path = substr(path, 1, length(path) - (tokenlength + 1));
return(0);
end;
my_content_characters:
proc( userToken, xmlToken, TokenLength )
returns( byvalue fixed bin(31) )
options( byvalue linkage(optlink) );
dcl userToken pointer;
dcl xmlToken pointer;
dcl tokenLength fixed bin(31);
dcl path char(133) varying based(userToken);
dcl chars char(32000) based;
dcl dataString char(1024);
dataString = path
!! ' = '''
!! substr(xmltoken -> chars, 1, tokenlength)
!! ''';';
get string(dataString) data (<fill in structure name here>);
return(0);
end;
Am 17.04.2012 12:44, schrieb JK:
> HI,