国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

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

2019-11-18 15:15:08
字體:
供稿:網(wǎng)友

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, "" );

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 深水埗区| 莫力| 福州市| 抚远县| 清水河县| 疏勒县| 麦盖提县| 寻甸| 宝兴县| 兴宁市| 赤城县| 和平区| 内黄县| 凤冈县| 郑州市| 安宁市| 洛浦县| 沙河市| 镶黄旗| 丹凤县| 蒲城县| 井研县| 阳春市| 民权县| 安乡县| 民县| 巴楚县| 平潭县| 西林县| 逊克县| 兰考县| 云南省| 类乌齐县| 溧阳市| 英德市| 荥经县| 秦皇岛市| 永吉县| 民丰县| 洪泽县| 萨迦县|