Home : Tutorials : XML Tutorial


Using DOM Parser and NameSpaces

Current DOM (Document Object Model) is under Level  1 Specification which can be downloaded from the W3C Site

The Document Object Model (DOM) provides APIs that let you create nodes, modify them, delete and rearrange them. However, the Level 1 DOM specification is silent on the subject of how to input and output. It tells you how a DOM has to operate, but does not cover methods for for reading or writing XML. As a result, you can't create a DOM from an existing XML file without going outside the DOM Level 1 specification. 

So Sun implemented it's process of Reading the XML file, which might change according to future specifications. Currently it's through FileInputStream and URLDataInputStream

DOM Parser internally uses SAX parser to parse the XML file and create the Tree. So all the errors thrown while parsing the XML file will be almost same as the SAX Parser.

Traversing Nodes

The org.w3c.dom.Node interface defines a number of methods you can use to traverse nodes, including getFirstChild, getLastChild, getNextSibling, getPreviousSibling, and getParentNode. Those operations are sufficient to get from anywhere in the tree to any other location in the tree. 


Using Namespaces

Names spaces is to avoid confusion when two different Element wants to have same Attribute Names or Elements names declared in the XML file clash with the External DTD, if we want to use the XHTML DTD for example. 

Note: At this point in time, the Sun's Java XML parsers do not support namespaces.

Home  Previous  Next


Home : Tutorials : XML Tutorial

 

Copyright© 1998-2004 All Rights Reserved. No portion of this site may be reproduced or redistributed without prior written permission from VistaEdge Technologies

All registered trademarks appearing on this site are the property of their respective owners. Java is a trademark or registered trademark of Sun Microsystems, Inc. in the United States and other countries. This site is not connected to Sun Microsystems, Inc. and is not sponsored by Sun Microsystems, Inc.