如何 使用 java 操纵 XML 文件
Introduction to XML and XML With Java
If you are looking for sample programs to parse a XML file using DOM/SAX parser or looking for a program to generate a XML file please proceed directly to programs.
This small tutorial introduces you to the basic concepts of XML and using Xerces parser for Java to generate and parse XML.
The intended audience are XML beginners with knowledge of Java.
Last updated:
03 Oct 2005.Modified programs runs in JDK 1.3, JDK 1.4 and JDK 1.5. Xerces parser is used with JDK 1.4 and 1.3.
Contents
1 Introduction
2 What is XML
3 Advantages of XML
3.1 Readability
3.2 Hierarchical
3.3 Language Independent
3.4 OS independent
4 Uses of XML
4.1 MetaContent
4.2 Messaging
4.3 Database
5 Parsers
5.1 DOM
5.2 SAX
5.3 When to use DOM Parser
5.4 When to use SAX Parser
5.5 Validating And Non Validating
5.6 Well Formedness
6 Programs
6.1 Parsing and Printing
6.1.1 Using DOM
6.1.2 Using SAX
6.2 Generating XML
7 Instructions to run these programs
7.1 Using JDK 1.5
7.2 Using JDK 1.4
7.3 Using JDK 1.3
Definitions
Introduction:
This is a gentle introduction to XML and using XML with Java. We see what makes XML tick and the advantages of XML . Also we have programs to show how to use Xerces parser for parsing and printing an XML document, to generate XML from arbitrary data.
These programs have been intentionally kept small to get the point across.
Top
2 What is XML ?
Extensible Markup Language
XML is text based markup language.
XML is more than html because html only deal with presentation and carries no information about the data itself.
In HTML
For example
<b>Seagull<b>
<i>3674<i>
<i> 34 </i>
could mean anything
In XML we represent it as.
<Personnel>
<Employee>
<Name>Seagull</Name>
相关文档:
堆栈是一种先进后出的数据结构,只能在一端进行输入或输出数据的操作 Stack类在java.util包中
向栈中输入数据的操作称为“压栈”;而从栈中输出数据的操作称为“弹栈”
1.构造方法:Stack()
2.常用方法
public Object push(Object data):向栈中输入数据,实现压栈 ......
1.树集TreeSet
TreeSet类在java.util包中
树集中的结点是按着其存放的数据的字典序一层一层地依次排列 在同一层中的结点从左到右按字典序递增排列
A.构造方法:TreeSet()
B.常用方法
& ......
1.散列集HashSet
HashSet类在java.util包中
A.构造方法:HashSet()
B.常用方法
public boolean add(Object o):向集合中添加指定元素o
&nb ......
甲骨文已经完成了对SUN公司的收购,于1月27日发布了对Sun各项业务的整合规划。总体上说,Oracle要成为软硬件一体化的整体解决方案的厂商。 以下就其对备受关注的Java方面的策略做个介绍。
Java SE:
1)推出JDK SE 7, 它将包括多个新的功能,如提高开发人员的效率,提供高性能,对多核芯片的支持等。
2)Sun的HotSpot ......
需要dom4j.jar文件 ,自行下载。 test.xml 1: <?xml version="1.0" encoding="gbk"?>
2:
3: <students>
4: <person sex="男" age="21">
5: <id>1</id>
6: <name>章治鹏</name>
7: <homepage&g ......