O'Reilly logo

Oracle Database 11g: Building Oracle XML DB Applications by Jinyu Wang

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

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); ...

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