xml在java中的简单应用

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

public class ListDOM
{
static Document document;
public static void main(String[] args) throws Exception
{
DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();

dbf.setIgnoringComments(true);
dbf.setIgnoringElementContentWhitespace(true);

DocumentBuilder db=dbf.newDocumentBuilder();

document=db.parse(new File("8_1.xml"));

Node root=document.getDocumentElement();
System.out.println(
"root:"+root.getNodeName());
}
}
8_1.xml
<?xml version=
"1.0" encoding="gb2312"?>
<booklist>
</booklist>

lunzi   2005-06-21 05:03:02 评论:0   阅读:529   引用:0

发表评论>>

署名发表(评论可管理,不必输入下面的姓名)

姓名:

主题:

内容: 最少15个,最长1000个字符

验证码: (如不清楚,请刷新)

Copyright@2004-2010 powered by YuLog