× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Shannon,

I don't think XML-INTO is designed to load separate elements into separate occurrences of a multiple-occurrence data structure. As far as it's concerned, there's only one data structure (the current occurrence) and it'll load the XML into that occurrence -- thus you get only one element.

Instead of using a multiple-occurrence data stucture (which is an obsolete tool, IMHO) please use a data structure array. This is what I've seen used in all of the examples out there!

In your code, you have this:

D Product DS Occurs(99)
D Upc 15A
D Price 6A
D Price_Type 1A

Change it so that it reads like this, instead:

D Product DS dim(99) qualified
D Upc 15A
D Price 6A
D Price_Type 1A

This should solve your problem... now it will see that it's an array, and load each product into a separate array element. When you try to read the contents of the subfields, you DO have to qualify them with the name of the DS array. In this example, you have Product as the name, so if you want to access the UPC subfield, you'd code:

x = 3;
Whatever = Product(x).Upc;

And that'd set the "whatever" field to the contents of the UPC subfield of the 3rd product that was loaded (in your example, 005150076080). I'm just telling you this so you understand the syntax of a qualified data structure array (since I get the impression that you haven't used them, you're using the older multiple-occurrence technique instead.)


Montross, Shannon wrote:
I am new to the XML-INTO process and I am trying to read an xml document
into a data-structure array and I am only getting the first item. Any
help would be appreciated.

Xml file.
<SecSvyWceDataSet>
<Product>
<Upc>005150000286</Upc>
<Price>126</Price>
<Price_Type>R</Price_Type>
</Product>
<Product>
<Upc>005150076426</Upc>
<Price>126</Price>
<Price_Type>R</Price_Type>
</Product>
<Product>
<Upc>005150076080</Upc>
<Price>126</Price>
<Price_Type>R</Price_Type>
</Product>
<Product>
<Upc>005150076050</Upc>
<Price>126</Price>
<Price_Type>R</Price_Type>
</Product>
</SecSvyWceDataSet>

Program.
D Product DS Occurs(99)
D Upc 15A
D Price 6A
D Price_Type 1A
D XML_Input S 256A Varying

/FREE XML_Input = 'test20071005.xml';

XML-INTO Product %XML(XML_Input: 'case=any ' +
'path=SecSvyWceDataSet/Product ' +
'allowmissing=yes ' +
'doc=file ');
*Inlr = *On; /END-FREE
When this program runs Products(1) has values for upc, price, and
price_type but array elements 2 through 15 are empty.
Thanks,

Shannon




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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

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.