Unless I completely mis-understand DOM Joe, XML-INTO is not a DOM parser.
It isn't necessarily a DOM parser but it has DOM-like features. The
bummer about DOM is that it uses up more CPU cycles than the
traditional SAX approach because you are going all over the document
(potentially) with "random access". I guess you could chalk it up as
making it easier for programmers and that CPU's are getting bigger all
the time.
<vendor>
Anyways, my team has been working on the next version of RPG-XML Suite
(www.rpg-xml.com) and we have started implementing DOM like features
as shown below. I wouldn't say it is "purist DOM" but instead DOM in
how we thought it worked the best :-) We were basically looking for a
way to easily gain access to data in an XML document without pointers
(or more specifically, procedure pointers).
/copy rxs,rxscp
D gError ds likeds(RXS_Error) inz
D gLineItemCnt s 10i 0
D gCompCnt s 10i 0
D gXml s like(RXS_XMLData)
D i1 s 10I 0
D i2 s 10I 0
D gOrd ds qualified inz
D cstId 7 0
D item likeds(gLineItem) dim(10)
D gLineItem ds qualified inz
D itemId 15a
D compId 6a dim(10)
/free
gXml =
'<order custId="123">' +
'<lineItem itemId="HAT111">' +
'<component id="11" />' +
'<component id="12" />' +
'<component id="13" />' +
'</lineItem>' +
'<lineItem itemId="HAT222">' +
'<component id="21" />' +
'<component id="22" />' +
'<component id="23" />' +
'</lineItem>' +
'</order>';
DOM_build( gXml : RXS_VAR : gError ); // Parse the document
into memory
gOrd.cstId = RXS_charToNbr(DOM_getData('/order@custId'): 0);
// Process lineItem elements
gLineItemCnt = DOM_getDataCount('/order/lineItem');
for i1 = 1 to gLineItemCnt;
gOrd.item(i1).itemId =
DOM_getData('/order/lineItem': i1: '@itemId');
// Process components for this specific line item.
gCompCnt = DOM_getDataCount('/order/lineItem': i1: '/component');
for i2 = 1 to gCompCnt;
gOrd.item(i1).compId(i2) =
DOM_getData('/order/lineItem': i1: '/component': i2 :'@id');
endfor;
endfor;
DOM_cleanup();
*inlr = *on;
/end-free
</vendor>
Aaron Bartell
http://mowyourlawn.com
As an Amazon Associate we earn from qualifying purchases.