网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > Java
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.客户端脚本,值得收藏.....
.JavaBean 101 8.
.Struts原理、开发及项目实施.
.使toString()的创建自动化.
.玩玩Spring之Rod Johnson与轮子理.
.理解接口.
.Java Script与Java Applet的综合.
.Spring JDBC抽象框架简化Web数据.
.iBATIS step by step (1).
.通过Struts应用MVC设计模型.
.写bean类的准则(1).
.你知道 Java 中 float 的取值范围.
.Java入门(6)Java数据类型.
.struts简单例子的分析(含代码注.
.基于OO模版技术的文档Web输出新法.
.在UML中表示Java继承和接口.
.如何在Java中实现Job Scheduling.
.TOMCAT+JIVE的安装配置.
.深入探讨EJB中新的消息驱动组件(.
.另一种bbs设计的思路.

Java核心代码例程之:(JAXP) DOM

发表日期:2008-1-5



import Javax.XML.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;

/**
 * DOMDemo uses JAXP to acquire a DocumentBuilder to build a DOM Document from an XML file.
 * The example XML file represents a shopping cart.
 *
 * The following JARs must be in your CLASSPATH:
 * - jaxp.jar
 * - xerces.jar (for SAX parser and DOM object implementations)
 *
 * Download JAXP (which includes these JARs) here: http://java.sun.com/xml/
 * Find additional Xerces info here: http://xml.apache.org/
 *
 **/

public class DOMDemo
{

  public static void main( String[] args )
  {
    try
    {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      System.out.println( "DocumentBuilderFactory classname: " + factory.getClass().getName() );

      DocumentBuilder builder = factory.newDocumentBuilder();
      System.out.println( "DocumentBuilder classname: " + builder.getClass().getName() );

      //parse the XML file and create the Document
      Document document = builder.parse( "cart.xml" );

      /*
      At this point, all data in the XML file has been parsed and loaded into memory
      in the form of a DOM Document object. The Document is a tree of Node objects.
      This printNode() method simply recurses through a Node tree and displays info
      about each node.**/
      printNode( document, "" );
上一篇:Java初学者如何迈出AOP第一步--使用Java 动态代理实现AOP 人气:540
下一篇:Java核心代码例程之:(JAXP) cart.xml 人气:613
浏览全部Java的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐