We had a VERY simple repeating XML and I parsed it like this:
Parse_Reply:
parse var sReply . '<c:referenceData>',
sReply_Element,
'</c:referenceData>',
sShrinking_Reply
do while length(sReply_Element) > 0
call Parse_Elements
parse var sShrinking_Reply . '<c:referenceData>',
sReply_Element,
'</c:referenceData>',
sShrinking_Reply
end
return
Parse_Elements:
parse var sReply_Element,
'<c:id>' sID '</c:id>' ,
'<c:shortDesc>'sShort_Desc '</c:shortDesc>',
'<c:longDesc>' sLong_Desc '</c:longDesc>',
'<c:sortOrder>' sSort_Order '</c:sortOrder>'
say 'ID :' sID
say 'Short Desc:' sShort_Desc
say 'Long Desc :' sLong_Desc
say 'Sort Order:' sSort_Order
line_out = ''
line_out = overlay(sID,line_out,1)
line_out = overlay(sShort_Desc,line_out,3)
line_out = overlay(sLong_Desc,line_out,58)
line_out = overlay(sSort_Order,line_out,117)
push line_out
"EXECIO 1 DISKW OUTDATA"
return
What's happening is that REXX finds the adta between the main tags <c:referenceData> and </c:referenceData>, puts that into sReply_Element and leaves the rest in sShrinking_Reply.
Then it calls Parse_Elements where the sub tags are parsed into variables.
Our XML looks like:
<root tag>
<c:referenceData>
<c:id>data</c:id>
<c:shortDesc>data</c:shortDesc>
<c:longDesc>data</c:longDesc>
<c:sortOrder>data</c:sortOrder>
</c:referenceData>
<c:referenceData>
<c:id>data</c:id>
<c:shortDesc>data</c:shortDesc>
<c:longDesc>data</c:longDesc>
<c:sortOrder>data</c:sortOrder>
</c:referenceData>
<c:referenceData>
<c:id>data</c:id>
<c:shortDesc>data</c:shortDesc>
<c:longDesc>data</c:longDesc>
<c:sortOrder>data</c:sortOrder>
</c:referenceData>
<root tag>