JavaEE_DOM

Today`s Famaous quotes here :      Successful people often change their methods instead of goals.

XML parser :

1.DOM,SAX,JDOM,DOM4J.

The First DOM (Document Object Model) ,Lets Start:

JavaCode : 


package test;

import java.io.File;
import org.w3c.dom.*;
import javax.xml.parsers.*;

public class DOMReader{
	public static void main(String[] args) {
		try{
			//This file name
			File file = new File("pathName");
			//get the factory of bulider
			DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
			//Create bulider
			DocumentBuilder builder = factory.newDocumentBuilder();
			//start parse this file 
			Document document = (Document) builder.parse(file);
			//Obtained by name 
			NodeList nl = document.getElementsByTagName("VALUE");
			//There are many Byte and data  so have to  for
					for(int i =0;i<nl.getLength();i++){
						System.out.println("Massage one" + document.getElementsByTagName("NO").item(i)
								.getFirstChild().getNodeValue());
					}
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}

2.Attributes :    Document, Element,node, nodeList,attribute ,comment  these are  sex  Attributes about DOM parser.

3.Level  : NO.1 DOM  , NO.2 DOM , NO.3 DOM  these are about time.

4.Methods  :  getElementById();   &    getElementByTagName();

5.Attributes  :parentNode、firstChild and  lastChild.

Note  :1. DOM(Document Object Model ) will waste memory . So i support use SAX or other parser.



Iparhan_Java  2016-6-23   GoodLuck!



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值