File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes beginner DOM iteration problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "beginner DOM iteration problem " Watch "beginner DOM iteration problem " New topic

beginner DOM iteration problem

kalle svensson

Joined: Oct 05, 2009
Posts: 13
hi, all ranchers!
My question is if there is any one here who can see what i am doing wrong with the current code sample. I have done this before but i cant
get it right this time. Is there anyone here that can help me to see what i am doing wrong? I would be very greatful for any hint or tip posted here.
My problem is that i must store values from a xml file in a array of String objects but i keep getting null values when i print out the array in
question. Here is my code so far.

Here is the beginning of the java code for the question in mind ...

And this is where i always get stuck. I keep getting null values in my contacts array when I am looping through it. I know there must be a lot of errors in my java code
but i am a complete rookie with so far only basic knowledges. I cant see why null values are stored in the contacts array? Can anyone explain what i am doing wrong and the origin of
the null values. Any hint or tip will be very much appreciated.
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Starting at line 21 you set four variables to null.

Then from lines 26 to 40 you have some code which can change at most one of those variables. So at least three of them must still be null after line 40.
I agree. Here's the link:
subject: beginner DOM iteration problem
It's not a secret anymore!