XML½âÎö·½·¨½²½â
XMLÏÖÔÚÒѾ³ÉΪһÖÖͨÓõÄÊý¾Ý½»»»¸ñʽ,ËüµÄƽ̨ÎÞ¹ØÐÔ,ÓïÑÔÎÞ¹ØÐÔ,ϵͳÎÞ¹ØÐÔ,¸øÊý¾Ý¼¯³ÉÓë½»»¥´øÀ´Á˼«´óµÄ·½±ã¡£¶ÔÓÚXML±¾ÉíµÄÓ﷨֪ʶÓë¼¼Êõϸ½Ú,ÐèÒªÔĶÁÏà¹ØµÄ¼¼ÊõÎÄÏ×,ÕâÀïÃæ°üÀ¨µÄÄÚÈÝÓÐDOM(Document Object Model),DTD(Document Type Definition),SAX(Simple API for XML),XSD(Xml Schema Definition),XSLT(Extensible Stylesheet Language Transformations),¾ßÌå¿É²ÎÔÄw3c¹Ù·½ÍøÕ¾Îĵµhttp://www.w3.org»ñÈ¡¸ü¶àÐÅÏ¢¡£
XMLÔÚ²»Í¬µÄÓïÑÔÀï½âÎö·½Ê½¶¼ÊÇÒ»ÑùµÄ,Ö»²»¹ýʵÏÖµÄÓï·¨²»Í¬¶øÒÑ¡£»ù±¾µÄ½âÎö·½Ê½ÓÐÁ½ÖÖ,Ò»ÖÖ½ÐSAX£¬ÁíÒ»ÖÖ½ÐDOM¡£SAXÊÇ»ùÓÚʼþÁ÷µÄ½âÎö,DOMÊÇ»ùÓÚXMLÎĵµÊ÷½á¹¹µÄ½âÎö¡£¼ÙÉèÎÒÃÇXMLµÄÄÚÈݺͽṹÈçÏÂ:
<?xml version="1.0" encoding="UTF-8"?>
<employees>
<employee>
<name>ddviplinux</name>
<sex>m</sex>
<age>30</age>
</employee>
</employees>
±¾ÎÄʹÓÃJAVAÓïÑÔÀ´ÊµÏÖDOMÓëSAXµÄXMLÎĵµÉú³ÉÓë½âÎö¡£
Ê×Ïȶ¨ÒåÒ»¸ö²Ù×÷XMLÎĵµµÄ½Ó¿ÚXmlDocument Ëü¶¨ÒåÁËXMLÎĵµµÄ½¨Á¢Óë½âÎöµÄ½Ó¿Ú¡£
package com.alisoft.facepay.framework.bean;
/**
*
* @author hongliang.dinghl
* ¶¨ÒåXMLÎĵµ½¨Á¢Óë½âÎöµÄ½Ó¿Ú
*/
public interface XmlDocument {
/**
* ½¨Á¢XMLÎĵµ
* @param fileName Îļþȫ·¾¶Ãû³Æ
*/
public void createXml(String fileName);
/**
* ½âÎöXMLÎĵµ
* @param fileName Îļþȫ·¾¶Ãû³Æ
*/
public void parserXml(String fileName);
}
1.DOMÉú³ÉºÍ½âÎöXMLÎĵµ
Ϊ XML ÎĵµµÄÒѽâÎö°æ±¾¶¨ÒåÁËÒ»×é½Ó¿Ú¡£½âÎöÆ÷¶ÁÈëÕû¸öÎĵµ£¬È»ºó¹¹½¨Ò»¸öפÁôÄÚ´æµÄÊ÷½á¹¹£¬È»ºó´úÂë¾Í¿ÉÒÔʹÓà DOM ½Ó¿ÚÀ´²Ù×÷Õâ¸öÊ÷½á¹¹¡£Óŵ㣺Õû¸öÎĵµÊ÷ÔÚÄÚ´æÖУ¬±ãÓÚ²Ù×÷£»Ö§³Öɾ³ý¡¢Ð޸ġ¢ÖØÐÂÅÅÁеȶàÖÖ¹¦ÄÜ£»È±µã£º½«Õû¸öÎĵµµ÷ÈëÄڴ棨°üÀ¨ÎÞÓõĽڵ㣩£¬ÀË·Ñʱ¼äºÍ¿Õ¼ä£»Ê¹Óó¡ºÏ£ºÒ»µ©½âÎöÁËÎĵµ»¹Ðè¶à´Î·ÃÎÊÕâЩÊý¾Ý£»Ó²¼þ×ÊÔ´³ä×㣨ÄÚ´æ¡¢CPU£©¡£
package com.alisoft.facepay.framework.bean;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.
Ïà¹ØÎĵµ£º
ͨ¹ýAsp.net(C#)Ó¦ÓóÌÐò¶ÁÈ¡±¾µØÉÏ´«µÄExcleÎļþ,´æ·Åµ½DataSetÖÐ,ͨ¹ýDataSetÖеķ½·¨Ö±½ÓÉú³ÉXMLÎļþ.
C# Code
if (this.FileUpload1.PostedFile != null)
{
string filename = this.FileUpl ......
SAX£¨Simple API for XML¼ò³ÆSAX£©Ê¼þÊÇÎÞ״̬µÄ£¬Ò²¾ÍÊÇ˵£¬µ±½ÓÊÕµ½×Ö·ûÊý¾ÝµÄʼþºó£¬²¢²»ÖªµÀ¸Ã×Ö·ûÊý¾ÝÊÇÄÄÒ»¸öÔªËصÄ
ÄÚÈÝ¡£Í¬ÑùµØ£¬µ±ÊÕµ½ÔªËØ¿ªÊ¼µÄʼþºó£¬Ò²ÎÞ·¨ÖªµÀ¸ÃÔªËØÊÇ·ñÓи¸ÔªËØ£¬ÊÇ·ñÓÐ×ÓÔªËØ£¬ÕâÊÇ
SAXºÍDOM²»Í¬µÄµØ·½¡£SAX½âÎöÆ÷±¾Éí²¢²»ÌṩԪËصÄÉÏÏÂÎÄÐÅÏ¢£¬ËùÓÐÏà¹ØÐÅÏ¢µÄ¼Ç¼ÐèÒªÎÒÃÇ×Ô
¼º±à³ ......
==========================================
xmlÎļþ
£¼?xml version="1.0" encoding="GB2312"?£¾
£¼RESULT£¾
£¼VALUE£¾
¡¡¡¡ £¼NO£¾A1234£¼/NO£¾
¡¡¡¡ £¼ADDR£¾ËÄ´¨Ê¡XXÏØXXÕòXX·X¶ÎXXºÅ£¼/ADDR£¾
£¼/VALUE£¾
£¼VALUE£¾
¡¡¡¡ £¼NO£¾B1234£¼/NO£¾
¡¡ ¡¡£¼ADDR£¾ËÄ´¨Ê¡XXÊÐXXÏçXX ......
½ñÌìÔÚÔËÓÃspringµÄPropertyPlaceholderConfigurerʱ·¢ÏÖÒ»¸öÓÐÒâ˼µÄÄÚÈÝ£¬µ±ÄãÔÚapplicationContextÖÐÅäÖÃÒ»¸öPropertyPlaceholderConfigurerµÄbeanʱ£¬ÓÐlocationºÍlocationsµÄÊôÐÔ£¬²»Ã÷˼Òâlocation¶ÔÓ¦Ò»¸ö.propertiesÎļþ£¬
locations¶ÔÓ¦¶à¸ö.propertiesÎļþ£¬³å×ÅÏë¿´Ò»ÏÂPropertyPlaceholderConfigurerµÄʵÏÖ»úÖ ......
Internet Explorer 5.0 ¶Ô XML ÌṩÄĸö¼¶±ðµÄÖ§³Ö£¿
¡¡¡¡Internet Explorer 5 ÌṩÏÂÁÐ XML Ö§³Ö£º
¡¡¡¡Ö±½Ó²é¿´ XML¡£Microsoft XML ʵÏÖÔÊÐíÓû§Í¨¹ýËûÃÇµÄ Web ä¯ÀÀÆ÷ʹÓà XSL »òÕß²ãµþÑùʽ±í (CSS) ²é¿´ XML£¬¾ÍÏó²é¿´ HTML ÎĵµÒ»Ñù¡£
¡¡¡¡¸ßÐÔÄÜ¡¢ÑéÖ¤ XML ÒýÇæ¡£Internet Explorer 4.0 ¿ª·¢ÈËÔ±ÊìϤµÄ XML ÒýÇ ......