Thank you for your example, Helge.

I believe I was able to get it to work.

Moses Nang
Integrated Merchandising Systems
(847) 583-7112

-----Original Message-----
From: WEB400 [mailto:web400-bounces@xxxxxxxxxxxx] On Behalf Of Helge Bichel
Sent: Thursday, May 08, 2014 5:30 PM
To: 'Web Enabling the IBM i (AS/400 and iSeries)'
Subject: Re: [WEB400] XML-INTO Example

An example on processing your xml.


h DFTACTGRP(*NO) ACTGRP(*CALLER)

h OPTION(*NODEBUGIO)

*--------------------------------------------------------------------

* XML tables

*--------------------------------------------------------------------

dcl-ds request qualified;

order likeds(t_order) dim(05); // max 5 orders

num_order int(10);

end-ds;



dcl-ds t_order qualified template;

nbr char(10);

item_list likeds(t_item_list);

num_item_list int(10);

end-ds;



dcl-ds t_item_list qualified template;

item char(15) dim(10); // max 10 items

num_item int(10);

end-ds;

d xmlstring s 2048A Varying
d xmlfile s 256A Varying
d xmloptions s 100A Varying
d idxorder s 5u 0
d idxitem s 5u 0
/free
exsr @Importxml;
*inlr = *on;
return;

begsr @Importxml;

xmloptions = 'doc=string +
case=any ns=remove +
allowextra=no allowmissing=yes +
countprefix=num_ +
path=request';

// use xmlfile and doc=file when input is from a stmf
xmlfile = '/somedir/somefile.xml';

xmlstring = '<request> +
<order> +
<nbr>123</nbr> +
<item_list> +
<item>abc</item> +
<item>def</item> +
</item_list> +
</order> +
<order> +
<nbr>456</nbr> +
<item_list> +
<item>abc</item> +
<item>def</item> +
<item>xyz</item> +
</item_list> +
</order> +
</request>';

clear request;

monitor;
Xml-Into request %xml(xmlstring : xmloptions);
on-error;
endMon;


for idxorder = 1 to request.num_order;

dsply request.order(idxorder).nbr;

if request.order(idxorder).num_item_list <> *zero;
for idxitem = 1 to request.order(idxorder)
.item_list
.num_item;
dsply request.order(idxorder)
.item_list
.item(idxitem);
endfor;
endif;

endfor;

endsr;

-----Oprindelig meddelelse-----
Fra: WEB400 [mailto:web400-bounces@xxxxxxxxxxxx] På vegne af Moses Nang
Sendt: 8. maj 2014 22:42
Til: web400@xxxxxxxxxxxx
Emne: [WEB400] XML-INTO Example

Hello,

I'm fairly new to using xml-into. I'm currently trying to write a program
that uses xml-into and %handler to parse order information. How can I use
xml-into and %handler to parse the xml and write them into separate header
and detail tables without having to specify the order nbr inside of the
item_list section. Anyone have an example I can check out? Below is a
watered down sample xml I need to parse:

<request>
<order>
<nbr>123</nbr>
<item_list>
<item>abc</item>
<item>def</item>
</item_list>
</order>
<order>
<nbr>456</nbr>
<item_list>
<item>abc</item>
<item>def</item>
<item>xyz></item>
</item_list>
</order>
</request>

Thanks,

Moses Nang
Integrated Merchandising Systems
(847) 583-7112
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
list To post a message email: WEB400@xxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/web400.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2021 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.