以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 DOM/SAX/XPath 』  (http://bbs.xml.org.cn/list.asp?boardid=11)
----  Using DOM to Traverse XML  (http://bbs.xml.org.cn/dispbbs.asp?boardid=11&rootid=&id=46816)


--  作者:skyblue523
--  发布时间:5/13/2007 12:32:00 PM

--  Using DOM to Traverse XML
Introduction
XML is now used frequently to model business data in large-scale applications. A common Java application task is to parse XML to retrieve its data. The Document Object Model (DOM) defines a set of interfaces for navigating and manipulating the content and structure of XML and HTML documents.
Objective
After reading this article you will be able to create a representation of an XML document in your Java program and traverse that representation in two different ways. You will be able to traverse a horizontal representation of the XML document, and you will be able to traverse a tree, or hierarchical, representation of the XML document.
The Document Object Model (DOM) in Detail
The DOM defines interfaces that allow programmers to navigate XML and HTML documents and also to manipulate their content and structure. The DOM is a specification of interfaces; it's not an implementation. Vendors are left to come up with their own implementation of DOM. Sun Microsystems has some DOM support in its Java XML Processing API. Other vendors that provide support are IBM, Oracle, and the Apache Software Foundation.
Getting Started
This article explores the traversal of DOM representations of XML documents from within Java applications. The Apache Software Foundation has implemented the optional interfaces of the DOM Level 2 Traversal-Range Recommendation in their Xerces project. You can download the Xerces JAR, which contains the files you'll need. Xerces also supports the optional interfaces defined in DOM Level 2 Events Recommendation. Make sure to place the xerces.jar file in your system CLASSPATH so the Java compiler will be able to locate the appropriate files.

W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
62.500ms