O'Reilly logo

MySQL™ and JSP™ Web Applications: Data-Driven Programming Using Tomcat and MySQL by James Turner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Generating XML

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)

Listing 14.7. Order.dtd
 <?xml version='1.0' encoding='UTF-8' ?> <!ELEMENT File (Order)*> <!ELEMENT Order (email_address, address, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required