SAX½âÎöXMLÎĵµ£¨×ª£©
package cn.com.xml.vo;
public class RosterVo {
private String id; //ѧºÅ
private String name; //ѧÉúÐÕÃû
private String age; //ÄêÁä
private String skill; //¿ÆÄ¿
private String score; //·ÖÊý
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getScore() {
return score;
}
public void setScore(String score) {
this.score = score;
}
public String getSkill() {
return skill;
}
public void setSkill(String skill) {
this.skill = skill;
}
}
===============================
package cn.com.xml.sax;
import java.util.ArrayList;
import java.util.List;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import cn.com.xml.vo.RosterVo;
public class ContentHanderImpl implements ContentHandler {
private RosterVo vo=null;
private List list=null; //´æ·Å¶à¸ölist
private String elementName=null; //½ÚµãÃû×Ö ,×÷Ϊ±êʶ
//½âÎöxmlÎÄ檔時ºò´¥·¢
public void startDocument() throws SAXException {
System.out.println("startDocument.....");
list=new ArrayList();
}
//½âÎöxmlÎĵµÖÐÔªËØ½ÚµãµÄʱºò´¥·¢ qName:½ÚµãÃû×Ö atts:ÊôÐÔ
public void startElement(String uri, String localName, String qName,
Attribut
Ïà¹ØÎĵµ£º
Õâ¸öÊDzÎÕÕibmÍøÕ¾ÉϵÄÎÄÕÂ×öµÄ¡£
xmlÔ´Îļþ£º
<?xml version="1.0"?>
<!DOCTYPE rss PUBLIC
"-//Netscape Communications//DTD RSS 0.91//EN"
"http://my.netscape.com/publish/formats/rss-0.91.dtd"
>
<rss version="0.91">
<channel>
<title>Meerkat: An Open2 Wire Servic ......
import java.awt.Image;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
public class createXml
{
public static boolean writeXml(String path,String dir,String wpath,String wname)
{
File[] files = ReaderListFiles(path);
boo ......
Ò».Éú³Édocument¶ÔÏó¡£
import org.jdom.*;
import org.jdom.input.SAXBuilder;
public class ReportDocUtil {
public ReportDocUtil() {
}
/**
* <p>Description:covert xml file to Document</p>
* @param url ¸ñʽxmlÎļþµÄ´æ·ÅµÄÏà¶Ô·¾¶
& ......
XMLÎļþµÄ½âÎö££libxml¿âº¯Êý½âÊÍ
ÕªÒª
LibxmlÊÇÒ»¸öÓÐÃâ·ÑÐí¿ÉµÄÓÃÓÚ´¦ÀíXML¡¢¿ÉÒÔÇáËÉ¿çÔ½¶à¸öƽ̨µÄCÓïÑÔ¿â¡£Õâ¸öÖ¸ÄÏÌṩËüµÄ»ù±¾º¯ÊýµÄÀý×Ó¡£
Ð÷ÂÛ
Libxml ÊÇÒ»¸öʵÏÖ¶Á¡¢´´½¨¼°²Ù×ÝXMLÊý¾Ý¹¦ÄܵÄCÓïÑÔ¿â¡£Õâ¸öÖ¸ÄÏÌṩÀý×Ó´úÂë²¢¸ø³öËü»ù±¾¹¦ÄܵĽâÊÍ¡£ÔÚÕâ¸öÏîÄ¿µÄÖ÷Ò³ÉÏÓÐLibxml¼°¸ü¶à¹ØÓÚËü¿ÉÓõÄ×ÊÁÏ¡ ......
XmlDocument xmldoc = new XmlDocument();//´´½¨xmlÎĵµ¶ÔÏó
XmlNode root;//¸ù½Úµã
xmldoc.Load(Server.MapPath("address.xml"));//¼ÓÔØxmlÎĵµ
root = xmldoc.DocumentEle ......