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

ʹÓÃSAX½âÎöXML

SAX£¨Simple API for XML¼ò³ÆSAX£©Ê¼þÊÇÎÞ״̬µÄ£¬Ò²¾ÍÊÇ˵£¬µ±½ÓÊÕµ½×Ö·ûÊý¾ÝµÄʼþºó£¬²¢²»ÖªµÀ¸Ã×Ö·ûÊý¾ÝÊÇÄÄÒ»¸öÔªËصÄ
ÄÚÈÝ¡£Í¬ÑùµØ£¬µ±ÊÕµ½ÔªËØ¿ªÊ¼µÄʼþºó£¬Ò²ÎÞ·¨ÖªµÀ¸ÃÔªËØÊÇ·ñÓи¸ÔªËØ£¬ÊÇ·ñÓÐ×ÓÔªËØ£¬ÕâÊÇ
SAXºÍDOM²»Í¬µÄµØ·½¡£SAX½âÎöÆ÷±¾Éí²¢²»ÌṩԪËصÄÉÏÏÂÎÄÐÅÏ¢£¬ËùÓÐÏà¹ØÐÅÏ¢µÄ¼Ç¼ÐèÒªÎÒÃÇ×Ô
¼º±à³ÌȥʵÏÖ
SaxXmlÀà¼ÓÔØXMLÊý¾ÝÁ÷£¬£¨Ä¿Ç°ÓÃ×Ö·û´®´úÌ棩£¬½¨Á¢½âÎö¹¤³§£¬Éú²úSAX½âÎö¶ÔÏó
import java.io.ByteArrayInputStream;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.SAXException;
public class SaxXml {
private SaxXml() {
       }
SaxXml(String xmlFile) {
        try{
    String xmltest = "<?xml version=\"1.0\" encoding=\"gb2312\"?>"
      +"<home>"
      +"<name>ÕÅÈý</name>"
      +"<sex>ÄÐ</sex>"
      +"<age>20</age>"
      +"</home>";   
      byte[] data1 = xml.getBytes();
  
      SAXParserFactory factory = SAXParserFactory.newInstance();
      factory.setValidating(true);
    SAXParser sax = factory.newSAXParser();
    sax.parse(new ByteArrayInputStream(data1), XmlHandler.handler/*new XmlHandler()*/ );
   } catch (ParserConfigurationException pce) {
    System.out.println("Could not create that parser.");
    System.out.println(pce.getMessage());
   } catch (SAXException saxe) {
    System.out.println("Problem wITh the SAX parser.");
    System.out.println(saxe.getMessage());
   } catch (Exception e) {
    e.printStackTrace();
  &n


Ïà¹ØÎĵµ£º

xmlÎļþ½á¹¹

Ò»¸öXMLÎļþͨ³£°üº¬ÎļþÍ·ºÍÎļþÌåÁ½´ó²¿·Ö
1.     ÎļþÍ·
XMLÎļþÍ·ÓÉXMLÉùÃ÷ÓëDTDÎļþÀàÐÍÉùÃ÷×é³É¡£ÆäÖÐDTDÎļþÀàÐÍÉùÃ÷ÊÇ¿ÉÒÔȱÉٵģ¬¹ØÓÚDTDÉùÃ÷½«ÔÚºóÐøµÄÄÚÈÝÖнéÉÜ£¬¶øXMLÉùÃ÷ÊDZØÐëÒªÓеģ¬ÒÔʹÎļþ·ûºÏXMLµÄ±ê×¼¹æ¸ñ¡£
ÔÚÇ°ÃæµÄFlowers.xmlÎļþÖеĵÚÒ»ÐдúÂ뼴ΪXMLÉùÃ÷£º
<?xml °æ ......

Java ¶ÔxmlÎļþµÄ¶Áд²Ù×÷

/**
* ÃèÊö£ºÊý¾Ý¿â³õʼ»¯»ù±¾Àà
*
* @×÷Õß ÍõȺ
* @´´½¨ÈÕÆÚ 2010-04-08
* @ÐÞ¸ÄÈË xxx
* @ÐÞ¸ÄÈÕÆÚ xxx
* @¼ì²éÈË xxx
* @¼ì²éÈÕÆÚ xxx
*/
import java.sql.SQLException;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.oumasoft.bstmanage.ibatis.SqlMapConfig;
import com.oumasof ......

javascript¶¯Ì¬×°ÈëXMLÊý¾Ý


ʹÓÃjavascript´´½¨Microsoft XML DOM,¾Í¿ÉÒÔÍê³ÉÕâÒ»¹¤×÷.
// ×°ÈëÊý¾Ý.
var source = new ActiveXObject("Microsoft.XMLDOM");
source.async = false
source.load("history.xml");
// ×°ÈëÑùʽ±í.
var stylesheet = new ActiveXObject("Microsoft.XMLDOM");
stylesheet.async = false
stylesheet.load( ......

XML ¸ñʽ

ÏÖÔÚÎÒÃÇÔÝÇÒʹÓÓ¼Çʱ¾”À´´´½¨ÎÒÃǵÄXMLÎļþ°É¡£ÏÈ¿´Ò»¸öXMLÎļþ£º 
¡¡¡¡Àý1 
¡¡¡¡¡´?xml version="1.0" encoding="gb2312" ?¡µ 
¡¡¡¡¡´²Î¿¼×ÊÁÏ¡µ 
¡¡¡¡ ¡´Êé¼®¡µ 
¡¡¡¡ ¡´Ãû³Æ¡µXMLÈëÞ«½â¡´/Ãû³Æ¡µ 
¡¡¡¡ ¡´×÷Õß¡µÕÅÈý¡´/×÷Õß¡ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ