DOM Parsing in Java
DOM parsing is the basis for XSLT/XQuery processing. It’s very convenient to use DOM APIs to access and update XML documents.
Basic DOM Parsing
Let’s get started with a simple DOM parsing example using Oracle XDK Java (DOMSimple.java):
Listing 4-1 DOM Parsing in Oracle XDK
package xmlbook.chp04;
import java.io.File;
import java.io.FileInputStream;
import oracle.xml.parser.v2.DOMParser;
import oracle.xml.parser.v2.XMLDocument;
import oracle.xml.parser.v2.XMLElement;
import oracle.xml.parser.v2.XMLNode;
import oracle.xml.parser.v2.XMLParser;
public class DOMSimple {
public static void main(String[] argv) {
DOMParser dp = new DOMParser();
dp.setAttribute(XMLParser.STANDALONE, Boolean.TRUE);
dp.setPreserveWhitespace(false); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access