Parsing an XML using DOM parser in Java in Recursive fashion

I need to parse an XML using DOM parser in Java. New tags can be added to the XML in future. Code should be written in such a way that even with new tags added there should not be any code change. I felt that parsing the XML recursively can solve this problem. Can any one please share sample Java code that parses XML recursively. Thanks in Advance.

[357 byte] By [AshokGuptaa] at [2007-11-26 18:10:02]
# 1

You don't get it. You don't write an XML parser. You just call an XML parser that somebody else has already written. In your case you call a DocumentBuilder to do the parsing and produce a DOM.

I have no idea whether DocumentBuilder does things recursively or not, but I don't care because it parses the XML for me.

DrClapa at 2007-7-9 5:42:12 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
I need to perform some task while the parsing the XML. I need to get the names of all the tags and if I reach a leaf I need to get the value of the leaf. I need to put all these values into a Map object. Please let me know if you have any suggestions.
AshokGuptaa at 2007-7-9 5:42:12 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

Actually, if you are planning to use DOM then you will be doing that task after you parse the data. But anyway, have you read any tutorials or books about how to process XML in Java? If not, my suggestion would be to start by doing that. You cannot learn that by fishing on forums. Try this one for example:

http://www.cafeconleche.org/books/xmljava/chapters/index.html

DrClapa at 2007-7-9 5:42:12 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...