|
Wow thanks very much Scott. As I continued googling and playing around I
realized that I had to name my fields the same as the elements but got
stuck because they named theirs with ELEMENT NAME=.
Still, I was a long way away from your example. Thanks again
On Tue, Apr 26, 2016 at 2:24 AM, Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx>
wrote:
Jack,
The format of the XML you have to deal with is unfortunate... but...
here's how you'd handle it with XML into. I've also added an example of
how you'd re-map the format into your original format if you'd like to do
that, so that its maybe a bit easier to work with.
D Element_t ds qualified
D template
D name 20a
D dataType 20a
D value 100a
D POItems DS qualified
D num_element 10i 0
D element likeds(Element_t) dim(99)
D myItem DS qualified
D po# 100A
D PickupDate 100A
D Response 100A
D Reason 100A
D PO_Found 100A
D Supplier_Num 100A
D Vendor_Ind 100A
D Supplier 100A
D Vendor_Name 100A
D Vendor_Num 100A
D Supplier_Name 100A
D Alt_Data 100A
D name s like(Element_t.name)
D options s 200a varying
D X s 10i 0
/free
options = 'path=VerifyPurchaseOrderResponse/+
VerifyPurchaseOrderResult/+
PurchaseOrders/+
purchaseOrderItem +
case=any +
datasubf=value +
countprefix=num_ +
doc=file';
xml-into poItems %XML('/tmp/results.txt':options);
for x = 1 to POItems.num_element;
name = poItems.element(x).name;
select;
when name='ORDER_NO';
myItem.po# = poItems.element(x).value;
when name='PICKUP_DATE';
myItem.pickupDate = poItems.element(x).value;
when name='RESPONSE';
myItem.response = poItems.element(x).value;
// ...etc ...
endsl;
endfor;
*inlr = *on;
Return;
On 4/26/2016 12:43 AM, Scott Klement wrote:
Jack,--
First of all, you are missing a slash between PurchaseOrders and
purchaseOrderItem in your path= statement.
Secondly... your data structure needs to match the XML tag names you
have in your document, but it does not.. The document has tags named
'Element', but the data structure has fields named po#, PickupDate,
Response, etc.
RPG maps the names exactly. So it will map a tag named <Element> into a
subfield of the data structure named 'Element'. It will never map a tag
named 'Element' into a subfield named 'po#'.
I wonder if you're confused by the fact that your document has a "name"
attribute? You might be thinking the name attribute is the same thing
as the name of the XML tag? It is not...
Hmm.. maybe I'll code up an example...
-SK
On 4/25/2016 8:00 PM, Jack Tucky wrote:
Given the following XML, what should I use for the path option?
<PurchaseOrders> should repeat up to 99 times.
Is there a place where I can view an error log?
<VerifyPurchaseOrderResponse xmlns="http://retailer.com/webservices/">
<VerifyPurchaseOrderResult>
<InquiryID>549790573</InquiryID>
<PurchaseOrders>
<PurchaseOrderItem>
<Element name="ORDER_NO" datatype="string">12316966</Element>
<Element name="PICKUP_DATE" datatype="datetime">4/21/2016 4:44:56
PM</Element>
<Element name="RESPONSE" datatype="string">Refuse</Element>
<Element name="REASON" datatype="string">PO Not on file</Element>
<Element name="PO_FOUND" datatype="string">N</Element>
<Element name="SUPPLIER_NUM" datatype="string"/>
<Element name="SPECIAL_VENDOR_IND" datatype="string"/>
<Element name="SUPPLIER" datatype="string"/>
<Element name="VENDOR_NAME" datatype="string"/>
<Element name="VENDOR_NUM" datatype="string"/>
<Element name="SUPPLIER_NAME" datatype="string"/>
<Element name="ALT_DATA_SOURCE" datatype="string">N</Element>
</PurchaseOrderItem>
</PurchaseOrders>
</VerifyPurchaseOrderResult>
</VerifyPurchaseOrderResponse>
I am getting an error that a variable doesn't match. Here is my
complete
code.
http://code.midrange.com/453a93ea26.html
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 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.