Can I use jdom Element.getChildren() method to do the job?
Yes, you can. Jdom gives you the tool to use. but DFS or BFS are still required to traversal the tree. SAX does already guarantee you to DFS traversal of the tree, since it is in the document order, which is naturally the same as DFS for a tree. Of course, I’m assuming you are familiar with the graph theory. It is a huge saving for both time/memory plus coding, the very precious programmer’s time.Actually, jdom is using SAX to build the tree. It depends on your needs, either way could be better for it. If only for traversal and/or simple search, SAX is obvious better. However, if you needs more than one pass to do the search, jdom would no doubt be a better choice.SAX (JDOM uses it internally) sequentially traverses the XML (the tree in flat text format, or built-in DFS result) to build the tree in memory. You want to traversal the tree again to get the all contents back. This is the most inefficient way to do it, since you do it twice. The second time is much more complicated than the