Client-Side Presentation Logic 613 public class DOMBuild {   private DocumentImpl myDoc;   private Element docElement;   public DOMBuild() {}   public void CreateRoot() {     myDoc = new DocumentImpl();     docElement = myDoc.createElement("sell-off");     myDoc.appendChild(docElement);   } AddATrip() is the main method in this class, it is called by the DealsFinder class to add <trip> nodes under the <sell-off> root element.   public void AddATrip(String tripNum,                        String region,                        String startDate,                        String duration,                        String location,                        String price,                        String commission) {     Element trip = myDoc.createElement("trip");     trip.setAttribute("number", tripNum);     trip.setAttribute("region", region);     Element sdate = myDoc.createElement("startdate");     sdate.appendChild(myDoc.createTextNode(startDate));     Element dur = myDoc.createElement("duration");     dur.appendChild(myDoc.createTextNode(duration));     Element loc = myDoc.createElement("location");     loc.appendChild(myDoc.createTextNode(location));     Element pr = myDoc.createElement("price");     pr.setAttribute("commission", commission);     pr.appendChild(myDoc.createTextNode(price));     trip.appendChild(sdate);     trip.appendChild(dur);     trip.appendChild(loc);     trip.appendChild(pr);     docElement.appendChild(trip);   } The writeDOMTree() method uses the DOMWriter class to create an XML document in a String representing the tree.   public void writeDOMTree(PrintWriter out)  {     try {       DOMWriter.print(out, myDoc);     } catch (Exception e) { e.printStackTrace(); }   } }