× 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.



Generally speaking, RPG doesn't initialize data structure elements unless you specifically tell it to. In the case of the XML-INTO, it doesn't initialize the children of an element until it actually accesses that element. UNLESS you put an INZ on the count variable in question!

d peanutDS ds QUALIFIED
d babyNut likeds(babyNutDS)DIM(10)
d countbabyNut 5i 0 inz

d babyNutDS QUALIFIED
d type 10a
D wieght 10a

That should address your problem. Or if you want to be more explicit, move a zero into the field before you do the XML-INTO. One thing, which is probably just a typo, but your data structure subfield "wieght" is spelled wrong.

The other thing you might want to check into is the XML-SAX opcode. XML-SAX will parse your document and call a handler that you write for each element in the document. That way, if you're only interested in babyNut structures, you can write your handler to only process babyNuts. For me, XML-SAX takes a little more work; it's more event driven than procedural. But it does offer some additional flexibility.

Joe


One thing I maybe should add, is that I realise by adding a countpeanut
to my notification datastructure I can
over come this issue by checking for that and then continuing if that is
present, i.e.> 0, but I have a very complex XML file I am reading
through and it would be a lot easier and cleaner if I can just specify
my counts on the elements I am actually interested on rather than a
parent 5 steps up the chain.

My assumption, maybe wrongly, was that any count fields I use in my
datastructures would be set to 0 if the element wasn't present.




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.