File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Java beginner- trying a DOM parser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Java beginner- trying a DOM parser " Watch "Java beginner- trying a DOM parser " New topic
Author

Java beginner- trying a DOM parser

ratna sargurp
Ranch Hand

Joined: Jan 12, 2010
Posts: 32
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
Bartender

Joined: Oct 14, 2005
Posts: 18651
    
    8

"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

Joined: Oct 13, 2005
Posts: 39393
    
  28
Too difficult for a "beginning Java" question. Moving thread.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

I think you should look at this again:

ratna sargurp wrote:
ratna sargurp
Ranch Hand

Joined: Jan 12, 2010
Posts: 32
Hi

Can you please explain what is wrong with this statement?
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java beginner- trying a DOM parser