This material is all covered very well in Part III of the online text for this portion of the course Working with XML: The Java API for XML Processing (JAXP) Tutorial
Here is the source code for the programs discussed in class
DomParser0.java
DomParser1.java
DomParser2.java
DomWriter2.java
book.xml
CD.html
Note: this only displays properly with Internet Explorer. Firefox cannot
process it properly
cd_catalog.xml
Here are some links to the online java documentation
Node
Document
Element
DocumentBuilderFactory
DocumentBuilder
String
Transformer