Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java beginner- trying a DOM parser

 
ratna sargurp
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am a Java beginner. I am trying to write a DOM parser that reads a folder with xml files. For each file, I would like to add an attribute which gets incremented, and I want to save the output file with the same name as the input file.

Here is my code. I am having difficulties in reading each file and putting the results out to the same filename as the input file name. Right now, my code only reads the first file and prints the result to the console.

Can the experts please help me achieve my goal here?

 
Paul Clapham
Sheriff
Posts: 21152
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"java begin", please check your private messages regarding an important administrative matter.

Thank you.

Oh, and by the way people will be more likely to read your post if the code is readable. Which, right now, it isn't. You can make it readable by posting it inside the "code" tags (see the buttons above the box you post in).
 
Campbell Ritchie
Sheriff
Pie
Posts: 49466
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too difficult for a "beginning Java" question. Moving thread.
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you should look at this again:

ratna sargurp wrote:
 
ratna sargurp
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Can you please explain what is wrong with this statement?
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I could however I won't just yet. Answer these questions:

What have you tried and found?
What didn't work exactly?
What does the method getElementsByTagName() do?
What does the method item() do? What does it parameter?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic