By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,650 Members | 1,493 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,650 IT Pros & Developers. It's quick & easy.

loop through a list of record [stored in xml] using JAR library and execute specific

P: 6
Hello there,

I have an xml file that has the following structure

Aggregation Actions
Aggregation
Actions

Aggregation Actions
Aggregation
Actions

...................
................
............

I am using java library classes (jar files) to iterate through the xml file as listed below

The code works fine. The only issue is that it only iterates over the actions of one aggregation (i.e. the first record in the xml)
Aggregation Actions
Aggregation
Actions

it ignores the 2nd, 3rd, 4th......records

Expand|Select|Wrap|Line Numbers
  1. for (Iterator aggActionsiterator = actionList.iterator(); aggActionsiterator.hasNext();)
  2. {
  3. AggregationActions aggregationActions = (AggregationActions) aggActionsiterator.next();
  4.  
  5.     ArrayList<Action> actions = (ArrayList<Action>) aggregationActions.getActions(); // this is for aggregation actions
  6.  
  7. // This iterates over the actions of ONE aggregation
  8.  
  9. for (Iterator aggActionsIterator = actions.iterator(); aggActionsIterator.hasNext();)
  10.             {
  11. Action action = (Action) aggActionsIterator.next();
  12.  
  13. if (action.getActionType() == ActionType.SUPPLY)
  14. {
  15. // do something for all the aggregation actions in the xml file that is of type supply. however it only does it for 1
  16. }
I need a way to iterate over the actions of all the aggregations, and do specific calculations on each aggregation depending on its actions.. Hope this question is clear. Thanks.
Nov 19 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.