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 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 Android Security Essentials Live Lessons this week in the Android 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
xml JAVA
sorting XML to another XML file
Recursion makes my brain hurt
Can anyone help?I still can't append records in xml...
Writing XML element