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

Writing a DOM Parser

There's no question that it's easier to write DOM-based code because you can access the entire document structure as a memory object rather than having to collect information as it passes by during a serial parse of the document. You can use the same DTD and XML, but the parser is totally different when written as a DOM implementation, as you can see in Listing 14.6.

Listing 14.6. DOMProductImporter.java
 package com.bfg.xml; import org.apache.xerces.dom.TextImpl; import org.xml.sax.SAXParseException; import org.apache.xerces.parsers.DOMParser; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import java.sql.*; ...

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