At the beginning of this chapter, you learned about using XML as a medium for doing data interchange. Suppose you want to send a vendor an XML file with order data in it. You could just write a method that creates the XML manually using prints, but this is dangerous because you might forget to include an end tag or you might make some other simple syntactic XML mistake. You can use DOM to generate a file on the fly from database data and be assured that it will be formatted as proper XML. Again, you need to start by defining a DTD for the XML file that's going to hold your orders (see Listing 14.7)
<?xml version='1.0' encoding='UTF-8' ?> <!ELEMENT File (Order)*> <!ELEMENT Order (email_address, address, ...