/** * DOMDemo uses JAXP to acquire a DocumentBuilder to build a DOM Document from an XML file. * The example XML file rePResents a shopping cart. * * The following JARs must be in your CLASSPATH: * - jaxp.jar * - xerces.jar (for SAX parser and DOM object implementations) * * Download JAXP (which includes these JARs) here: http://java.sun.com/xml/ * Find additional Xerces info here: http://xml.apache.org/ * **/
//parse the XML file and create the Document Document document = builder.parse( "cart.xml" );
/* At this point, all data in the XML file has been parsed and loaded into memory in the form of a DOM Document object. The Document is a tree of Node objects. This printNode() method simply recurses through a Node tree and displays info about each node.**/ printNode( document, "" );