Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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


Ïà¹ØÎĵµ£º

JavaÓëXMLÁªºÏ±à³ÌÖ®DOMƪ

DOM³õ²½
DOMÊÇDocument Object ModelµÄËõд£¬¼´Îĵµ¶ÔÏóÄ£ÐÍ¡£Ç°Ãæ˵¹ý£¬XML½«Êý¾Ý×é֯Ϊһ¿ÅÊ÷£¬ËùÒÔDOM¾ÍÊǶÔÕâ¿ÅÊ÷µÄÒ»¸ö¶ÔÏóÃèÐð¡£Í¨Ë×µÄ˵£¬¾ÍÊÇͨ¹ý½âÎöXMLÎĵµ£¬ÎªXMLÎĵµÔÚÂß¼­ÉϽ¨Á¢Ò»¸öÊ÷Ä£ÐÍ£¬Ê÷µÄ½ÚµãÊÇÒ»¸ö¸ö¶ÔÏó¡£ÎÒÃÇͨ¹ý´æÈ¡ÕâЩ¶ÔÏó¾ÍÄܹ»´æÈ¡XMLÎĵµµÄÄÚÈÝ¡£
ÏÂÃæÎÒÃÇÀ´¿´Ò»¸ö¼òµ¥µÄÀý×Ó£¬¿´¿´ÔÚDOMÖ ......

ʹÓÃkxml½âÎöxmlÎļþ(Ò»)

Õâ¸öÊ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 ......

xml Îĵµ½âÎö


XMLÎļþµÄ½âÎö£­£­libxml¿âº¯Êý½âÊÍ
ÕªÒª
LibxmlÊÇÒ»¸öÓÐÃâ·ÑÐí¿ÉµÄÓÃÓÚ´¦ÀíXML¡¢¿ÉÒÔÇáËÉ¿çÔ½¶à¸öƽ̨µÄCÓïÑÔ¿â¡£Õâ¸öÖ¸ÄÏÌṩËüµÄ»ù±¾º¯ÊýµÄÀý×Ó¡£
Ð÷ÂÛ
Libxml ÊÇÒ»¸öʵÏÖ¶Á¡¢´´½¨¼°²Ù×ÝXMLÊý¾Ý¹¦ÄܵÄCÓïÑÔ¿â¡£Õâ¸öÖ¸ÄÏÌṩÀý×Ó´úÂë²¢¸ø³öËü»ù±¾¹¦ÄܵĽâÊÍ¡£ÔÚÕâ¸öÏîÄ¿µÄÖ÷Ò³ÉÏÓÐLibxml¼°¸ü¶à¹ØÓÚËü¿ÉÓõÄ×ÊÁÏ¡ ......

Winform Àï¶ÔxmlÎļþ½øÐÐxslת»»

C# code
// Load the style sheet.
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load("output.xsl");
// Execute the transform and output the results to a file.
xslt.Transform("books.xml", "books.html");
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ