java¶ÁÈ¡xml¼¸ÖÖ·½·¨
1£©DOM£¨JAXP Crimson½âÎöÆ÷£©
DOMÊÇÓÃÓëƽ̨ºÍÓïÑÔÎ޹صķ½Ê½±íʾXMLÎĵµµÄ¹Ù·½W3C±ê×¼¡£DOMÊÇÒÔ²ã´Î½á¹¹×éÖ¯µÄ½Úµã»òÐÅϢƬ¶ÏµÄ¼¯ºÏ¡£Õâ¸ö²ã´Î½á¹¹ÔÊÐí¿ª·¢ÈËÔ±ÔÚÊ÷ÖÐÑ°ÕÒ
Ìض¨ÐÅÏ¢¡£·ÖÎö¸Ã½á¹¹Í¨³£ÐèÒª¼ÓÔØÕû¸öÎĵµºÍ¹¹Ôì²ã´Î½á¹¹£¬È»ºó²ÅÄÜ×öÈκι¤×÷¡£ÓÉÓÚËüÊÇ»ùÓÚÐÅÏ¢²ã´ÎµÄ£¬Òò¶øDOM±»ÈÏΪÊÇ»ùÓÚÊ÷»ò»ùÓÚ¶ÔÏóµÄ¡£DOM
ÒÔ¼°¹ãÒåµÄ»ùÓÚÊ÷µÄ´¦Àí¾ßÓм¸¸öÓŵ㡣Ê×ÏÈ£¬ÓÉÓÚÊ÷ÔÚÄÚ´æÖÐÊdz־õģ¬Òò´Ë¿ÉÒÔÐÞ¸ÄËüÒÔ±ãÓ¦ÓóÌÐòÄܶÔÊý¾ÝºÍ½á¹¹×÷³ö¸ü¸Ä¡£Ëü»¹¿ÉÒÔÔÚÈκÎʱºòÔÚÊ÷ÖÐÉÏÏÂ
µ¼º½£¬¶ø²»ÊÇÏñSAXÄÇÑùÊÇÒ»´ÎÐԵĴ¦Àí¡£DOMʹÓÃÆðÀ´Ò²Òª¼òµ¥µÃ¶à¡£
2£©SAX
SAX´¦ÀíµÄÓŵã·Ç³£ÀàËÆÓÚÁ÷ýÌåµÄÓŵ㡣·ÖÎöÄܹ»Á¢¼´¿ªÊ¼£¬¶ø²»ÊǵȴýËùÓеÄÊý¾Ý±»´¦Àí¡£¶øÇÒ£¬ÓÉÓÚÓ¦ÓóÌÐòÖ»ÊÇÔÚ¶ÁÈ¡Êý¾Ýʱ¼ì²éÊý¾Ý£¬Òò´Ë²»ÐèÒª½«Êý
¾Ý´æ´¢ÔÚÄÚ´æÖС£Õâ¶ÔÓÚ´óÐÍÎĵµÀ´ËµÊǸö¾Þ´óµÄÓŵ㡣ÊÂʵÉÏ£¬Ó¦ÓóÌÐòÉõÖÁ²»±Ø½âÎöÕû¸öÎĵµ£»Ëü¿ÉÒÔÔÚij¸öÌõ¼þµÃµ½Âú×ãʱֹͣ½âÎö¡£Ò»°ãÀ´Ëµ£¬SAX»¹±È
ËüµÄÌæ´úÕßDOM¿ìÐí¶à¡£
Ñ¡ÔñDOM»¹ÊÇÑ¡ÔñSAX£¿ ¶ÔÓÚÐèÒª×Ô¼º±àд´úÂëÀ´´¦ÀíXMLÎĵµµÄ¿ª·¢ÈËÔ±À´Ëµ£¬ Ñ¡ÔñDOM»¹ÊÇSAX½âÎöÄ£ÐÍÊÇÒ»¸ö·Ç³£ÖØÒªµÄÉè¼Æ¾ö²ß¡£ DOM²ÉÓý¨Á¢Ê÷ÐνṹµÄ·½Ê½·ÃÎÊXMLÎĵµ£¬¶øSAX²ÉÓõÄʼþÄ£ÐÍ¡£
DOM½âÎöÆ÷°ÑXMLÎĵµ×ª»¯ÎªÒ»¸ö°üº¬ÆäÄÚÈݵÄÊ÷£¬²¢¿ÉÒÔ¶ÔÊ÷½øÐбéÀú¡£ÓÃDOM½âÎöÄ£Ð͵ÄÓŵãÊDZà³ÌÈÝÒ×£¬¿ª·¢ÈËÔ±Ö»ÐèÒªµ÷Óý¨Ê÷µÄÖ¸ÁȻºóÀûÓÃ
navigation
APIs·ÃÎÊËùÐèµÄÊ÷½ÚµãÀ´Íê³ÉÈÎÎñ¡£¿ÉÒÔºÜÈÝÒ×µÄÌí¼ÓºÍÐÞ¸ÄÊ÷ÖеÄÔªËØ¡£È»¶øÓÉÓÚʹÓÃDOM½âÎöÆ÷µÄʱºòÐèÒª´¦ÀíÕû¸öXMLÎĵµ£¬ËùÒÔ¶ÔÐÔÄܺÍÄÚ´æµÄÒª
Çó±È½Ï¸ß£¬ÓÈÆäÊÇÓöµ½ºÜ´óµÄXMLÎļþµÄʱºò¡£ÓÉÓÚËüµÄ±éÀúÄÜÁ¦£¬DOM½âÎöÆ÷³£ÓÃÓÚXMLÎĵµÐèҪƵ·±µÄ¸Ä±äµÄ·þÎñÖС£
SAX½âÎöÆ÷²ÉÓÃÁË»ùÓÚʼþµÄÄ£ÐÍ£¬ËüÔÚ½âÎöXMLÎĵµµÄʱºò¿ÉÒÔ´¥·¢Ò»ÏµÁеÄʼþ£¬µ±·¢ÏÖ¸ø¶¨µÄtagµÄʱºò£¬Ëü¿ÉÒÔ¼¤»îÒ»¸ö»Øµ÷·½·¨£¬¸æË߸÷½·¨Öƶ¨
µÄ±êÇ©ÒѾÕÒµ½¡£SAX¶ÔÄÚ´æµÄÒªÇóͨ³£»á±È½ÏµÍ£¬ÒòΪËüÈÿª·¢ÈËÔ±×Ô¼ºÀ´¾ö¶¨ËùÒª´¦ÀíµÄtag.ÌرðÊǵ±¿ª·¢ÈËÔ±Ö»ÐèÒª´¦ÀíÎĵµÖÐËù°üº¬µÄ²¿·ÖÊý¾Ý
ʱ£¬SAXÕâÖÖÀ©Õ¹ÄÜÁ¦µÃµ½Á˸üºÃµÄÌåÏÖ¡£µ«ÓÃSAX½âÎöÆ÷µÄʱºò±àÂ빤×÷»á±È½ÏÀ§ÄÑ£¬¶øÇÒºÜÄÑͬʱ·ÃÎÊͬһ¸öÎĵµÖеĶദ²»Í¬Êý¾Ý¡£
3£©JDOM http://www.jdom.org
JDOMµÄÄ¿µÄÊ
Ïà¹ØÎĵµ£º
¼ÙÉèxmlÎļþÊÇ
<?xml version="1.0" encoding="gb2312" ?>
- <books auth="wren">
- <book id="B01">
<name>¹þÀﲨÌØ </name>
<price>10 </price>
<memo>ÕâÊÇÒ»±¾ºÜºÃ¿´µÄÊé¡£ </memo>
</book>
- <boo ......
XMLµÄ²úÉú?
XMLµÄÈ«³ÆÊÇExtensible Markup Language,Òâ˼ÊÇ¿ÉÀ©Õ¹µÄ±ê¼ÇÓïÑÔ£¬ËüÊDZê׼ͨÓñê¼ÇÓïÑÔ(Standard Generalized Markup Language, SGML)µÄÒ»¸ö×Ó¼¯¡£SGML¹¦Äܷdz£Ç¿´ó£¬ÊÇ¿ÉÒÔ¶¨Òå±ê¼ÇÓïÑÔµÄÔªÓïÑÔ¡£
W3C×éÖ¯ÓÚ2004Äê2ÔÂ4ÈÕ£¬·¢²¼ÁËXML1.1µÄÍƼö±ê×¼£¬ÕâÊÇ×îеÄXML°æ±¾£¬²»¹ýÄ¿Ç°´ó¶àÊýµÄÓ¦Óû¹ÊÇ»ùÓÚXML1.0µÄ ......
Ö÷Ìâ
±¾ OBE ½Ì³Ì°üÀ¨ÏÂÁÐÖ÷Ì⣺
¸ÅÊö
Çé¾°
Ñé֤ǰÌáÌõ¼þ
ÔÚ ODI ÖÐн¨ÏîÄ¿
Ϊ XML Îļþ²åÈëÐÂÄ£ÐÍ
ΪÊý¾Ý¿â±í CLIENT ²åÈëÄ£ÐÍ
ɾ³ý CITY_CLIENT µÄÔ¼Êø¸±±¾
ÔÚ CLIENT Êý¾Ý´æ´¢ÉÏÉèÖà ODI Ô¼Êø
µ¼Èë֪ʶģ¿é
´´½¨ÓÃÓÚ¼ÓÔØ XML ÎļþµÄнӿÚ
Ö´ÐгÌÐò°ü²¢²âÊÔ½á¹û
²é¿´½Ó¿ÚÖ´ÐеÄÔ¼Êø´íÎó
×ܽá
Ïà¹ØÐÅÏ¢
......
import java.util.Stack;
/**
* JAVA»ñµÃÒ»¸öÊý×éµÄÖ¸¶¨³¤¶ÈµÄÅÅÁÐ×éºÏ¡£<br>
*
* @author JAVAÊÀ¼ÍÍø(java2000.net, laozizhu.com)
*/
public class TestSequenceAll {
public static void main(String[] args) {
TestSequenceAll t = new TestSequenceAll();
Ob ......