XML Tutorials - Herong's Tutorial Examples - v5.21, by Dr. Herong Yang
Outdated: Using DOM Implementation Provided in JDK 1.4
This section provides a tutorial example on how to use the DOM interface included in JDK 1.4, which actually uses DOM implementation provided in the org.apache.crimson package.
Here is a program to show how different packages are used together to parse an XML file into a DOM document object:
/* DOMParser.java * Copyright (c) HerongYang.com. All Rights Reserved. */ import java.io.*; import javax.xml.parsers.*; import org.w3c.dom.*; import org.xml.sax.*; class DOMParser { public static void main(String[] args) { try { File x = new File(args[0]); DocumentBuilderFactory f = DocumentBuilderFactory.newInstance(); System.out.println(f.toString()); DocumentBuilder b = f.newDocumentBuilder(); System.out.println(b.toString()); Document d = b.parse(x); System.out.println(d.toString()); DOMImplementation i = d.getImplementation(); System.out.println(i.toString()); } catch (ParserConfigurationException e) { System.out.println(e.toString()); } catch (SAXException e) { System.out.println(e.toString()); } catch (IOException e) { System.out.println(e.toString()); } } }
If you run this sample program, you will get:
C:\herong>java DOMParser hello.xml org.apache.crimson.jaxp.DocumentBuilderFactoryImpl@1c78e57 org.apache.crimson.jaxp.DocumentBuilderImpl@13e8d89 org.apache.crimson.tree.XmlDocument@1cfb549 org.apache.crimson.tree.DOMImplementationImpl@1820dda
Note that:
Notes and sample codes in this section are based on JDK 1.4.1_01.
Table of Contents
Introduction of XML (eXtensible Markup Language)
DOM (Document Object Model) Programming Interface
SAX (Simple API for XML) Programming Interface
DTD (Document Type Definition) Introduction
Validating an XML Document against the Specified DTD Document Type
XSD (XML Schema Definition) Introduction
Validating XML Documents Against Specified XML Schemas
XSL (Extensible Stylesheet Language) Introduction
XSLT (XSL Transformations) Introduction
XSLT Elements as Programming Statements
Control and Generate XML Element in the Result
PHP Extensions for XML Manipulation
XML Tools Plugin for Notepad++
XML Plugin Packages for Atom Editor
XML 1.1 Changes and Parsing Examples
Outdated: Downloading and Installing Notepad++ 6.8
Outdated: Downloading and Installing Notepad++ 5.9
►Outdated: Using DOM Implementation Provided in JDK 1.4