This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Smiple(?) SAX-parser print all nodes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Smiple(?) SAX-parser print all nodes" Watch "Smiple(?) SAX-parser print all nodes" New topic
Author

Smiple(?) SAX-parser print all nodes

Sebastian Green
Ranch Hand

Joined: Jan 30, 2004
Posts: 136
Hi i found this example on the net, its supose to print every element and the element value. But I can get it to work.



Could someone help so print out the whole xml-file. Thanks!


/ Sebastian<br />No blog, No homepage, No life?
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
When you do

you're only getting a list of the direct children of 'el', not all descendants of 'el'.

You need to do some kind of a recursive method like this to traverse the whole DOM tree. Another option would be to do something like this.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Sebastian Green
Ranch Hand

Joined: Jan 30, 2004
Posts: 136
Thanks Lasse, I will test that later and get back to this topic.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Smiple(?) SAX-parser print all nodes
 
Similar Threads
Writing XML element
xml JAVA
sorting XML to another XML file
Can anyone help?I still can't append records in xml...
Recursion makes my brain hurt