|
Thank you Barbara,
My problem is that I have more than 1 outer element :
<outer><id>O1</>
<object><id>O1</id>
<parts>
<part><qty>100</qty><id>A1</id><cost>12.03</cost></part>
<part><qty>2</qty><id>A4</id><cost>1.98</cost></part>
</parts>
</object>
<object><id>O2</id>
<parts>
<part><qty>100</qty><id>B1</id><cost>12.03</cost></part>
<part><qty>2</qty><id>B4</id><cost>1.98</cost></part>
</parts>
</object>
</outer>
<outer><id>O2</> ... etc
The handler returns all the part elements and cannot know which outer id
the parts are related to, is that correct?
Assuming there is an outer element holding the <object> elements
<outer>
<object><id>O1</id>
<parts>
<part><qty>100</qty><id>A1</id><cost>12.03</cost></part>
<part><qty>2</qty><id>A4</id><cost>1.98</cost></part>
</parts>
</object>
<object><id>O2</id>
<parts>
<part><qty>100</qty><id>B1</id><cost>12.03</cost></part>
<part><qty>2</qty><id>B4</id><cost>1.98</cost></part>
</parts>
</object>
</outer>
You specify the path that gets to each part.
path=outer/object/parts/part
It will find every instance of an XML element that has that path from the
beginning of the document, so it will find all 4.
DATA.QTY(1) = 100
DATA.ID(1) = 'A1'
DATA.COST(1) = 012.03
DATA.QTY(2) = 2
DATA.ID(2) = 'A4'
DATA.COST(2) = 001.98
DATA.QTY(3) = 100
DATA.ID(3) = 'B1'
DATA.COST(3) = 012.03
DATA.QTY(4) = 2
DATA.ID(4) = 'B4'
DATA.COST(4) = 001.98
On Wed, 15 Jan 2025 at 21:33, Dave <dfx1@xxxxxxxxxxxxxx> wrote:
Hi,--
The simple example given by IBM to demonstrate the use of the %handler
function of XML-INTO uses an xml structure similar to this :
options = 'doc=file path= parts/part';
<parts>
<part><qty>100</qty><id>A1</id><cost>12.03</cost></part>
<part><qty>2</qty><id>A4</id><cost>1.98</cost></part>
</parts>
How would I indicate the path if parts is nested in another array like
this ? :
<object><id>O1</>
<parts>
<part><qty>100</qty><id>A1</id><cost>12.03</cost></part>
<part><qty>2</qty><id>A4</id><cost>1.98</cost></part>
</parts>
</object>
<object><id>O2</>
<parts>
<part><qty>100</qty><id>B1</id><cost>12.03</cost></part>
<part><qty>2</qty><id>B4</id><cost>1.98</cost></part>
</parts>
</object>
Thanks
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.