Javaͨ¹ýXML SchemaУÑéXML
Javaͨ¹ýXML SchemaУÑéXML
XMLµÄУÑéÔÚXML´¦ÀíÖзdz£³£¼û£¬Èç¹ûûÓÐÓÐЧµÄ°ì·¨À´Ð£ÑéXMLµÄºÏ·¨ÐÔ£¬ÍùÍù»áµ¼ÖºܶàÎÊÌâ¡£
XMLµÄУÑéÊÇͨ¹ýXML Schema£¨XSD£© »òDTDÎļþµÄÓï·¨¹æ·¶À´Ð£ÑéµÄ¡£DTDÏÖÔÚÔ½À´Ô½²»ÊÜ»¶ÓÁË£¬ÔÚ´ËÑ¡ÓÃXSDÀ´Ð£Ñé¡£
JavaУÑéXMLÊǼþºÍ³¶µµÄÊÂÇ飬ÒòΪSunµÄXMLÏà¹ØÈí¼þ°ü»áÁîÄãÔÆÀïÎíÀï¡£
W3CÕâ¿éµÄXMLÏà¹ØµÄ¹æ·¶Ï൱µÄ¶à£¬ÕâÒ²Êǵ¼ÖÂXML´¦ÀíÆ÷ÆðÀ´·Ñ¾¢µÄÖ÷ÒªÔÒò¡£ÒªÏ뾫ͨÕâЩ¹æ·¶ºÍÏà¹ØµÄAPI£¬ÊµÔÚÊÇÒìÏëÌ쿪£¨ÐµĹ淶ÔÚ²»Í£³ö£¬Ô½À´Ô½¶à£¡£©¡£
УÑéµÄÔÀíÊÇͨ¹ý¶ÁÈ¡½âÎöXMLµÄʱºòÉèÖÃУÑéµÄXSDºÍУÑé´íÎó´¦ÀíÆ÷£¬Ë³±ãУÑéµÄ¡£
ÏÂÃæ²»³¶ÕâЩ·Ï»°ÁË£¬ÎÒÓÃDOM4j½áºÏjavaxml apiʹÓÃXSDÀ´Ð£ÑéÒ»¸öxmlÓÐЧÐÔ£¬ÏÂÃæÕâ¸öÀý×ÓËäÈ»ºÍõ¿½Å£¬µ«ÊÇÒ²·ÑÁËÒ»·¬¹¦·ò£¬·Å³öÀ´´ó¼ÒÑо¿°É£¬ÓиüºÃµÄʵÏÖҲϣÍûÄܺÍÎÒһͬ·ÖÏí¡£
Àý×ÓÈçÏ£º
XMLÎļþ
<?xml version="1.0"?>
<note
xmlns="http://www.w3school.com.cn"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3school.com.cn file:///D:/_dev_stu/xsdtest/src/note.xml">
<to>George</to>
<from>John</from>
<heading>Reminder</heading>
<body>Don't forget the meeting this weekend!</body>
</note>
XSDÎļþ
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3school.com.cn"
xmlns="http://www.w3school.com.cn"
elementFormDefault="qualified">
<xs:element name="note">
<xs:complexType>
&
Ïà¹ØÎĵµ£º
½ñÌìÊÇ2010Äê1ÔÂ23ºÅÁ賿£¬ÎÒºöÈ»×öÁ˸ö¾ö¶¨£¬Ï£Íû²»»áÁ÷²ú¡£ËäÈ»×î½üÒªºÃºÃѧϰӢÓ»¹ÒªÓÃC#Ϊһ¸öŮʿ×öÒ»¸öÔ±¹¤¹ÜÀíϵͳ¡£µ«ÊÇÎÒ¾ö¶¨Ã¿Ìì³é³öÖÁÉÙ3СʱºÃºÃѧϰjava¿´Á½ÖÜÄÜѧµ½Ê²Ã´¶«Î÷¡£
ÏÖÔÚ½ö½ö»á°²×°ÅäÖÃjdk£¬ÓøöecpliseºÍJcreator±àдµã¼òµ¥³ÌÐò¡£Á¬jdk
api¶¼²»È ......
java ´úÂë
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList; ......
ÏÂÔØÒ»¸öJDKµÄ°²×°°ü£¬ÎÒÏÂÔصÄÊÇjdk-6u10-rc2-bin-b32-windows-i586-p-12_sep_2008.exe£¬´ó¼Ò¿ÉÒÔÈ¥ÍøÉÏËÑË÷£¬Ò²¿ÉÒÔÈ¥¹Ù·½
ÏÂÔØ¡£
ÏÂÔغ󣬵ã»÷exeÎļþ£¬Ò»Ö±ÏÂÒ»²½µÄ°²×°£¬Óöµ½ÐèҪѡÔñ°²×°Ä¿Â¼µÄ£¬¿ÉÒÔĬÈÏ£¬Ò²¿ÉÒÔ×Ô¼ºÖ¸¶¨£¨ÀýÈçÖ¸¶¨°²×°ÔÚD:\Program Files\Java)
°²×°¹ý³ÌÓÐÁ½´ÎÑ¡Ôñ·¾¶µÄ£¬Ò»´ÎÊǶÔjdk1.6.0_10½ø ......
1. ³éÏó
³éÏó¾ÍÊǺöÂÔÒ»¸öÖ÷ÌâÖÐÓ뵱ǰĿ±êÎ޹صÄÄÇЩ·½Ã棬ÒÔ±ã¸ü³ä·ÖµØ×¢ÒâÓ뵱ǰĿ±êÓйصķ½Ãæ¡£³éÏó²¢²»´òËãÁ˽âÈ«²¿ÎÊÌ⣬¶øÖ»ÊÇÑ¡ÔñÆäÖеÄÒ»²¿·Ö£¬ÔÝʱ²»Óò¿·Öϸ½Ú¡£³éÏó°üÀ¨Á½¸ö·½Ã棬һÊǹý³Ì³éÏ󣬶þÊÇÊý¾Ý³éÏó¡£
2. ¼Ì³Ð
¼Ì³ÐÊÇÒ»ÖÖÁª½áÀàµÄ²ã´ÎÄ£ÐÍ£¬²¢ÇÒÔÊÐíºÍ¹ÄÀøÀàµÄÖØÓã¬ËüÌṩÁËÒ»ÖÖÃ÷È· ......
JavaÖÐͨ¹ýimplements SerializableÀ´ÊµÏÖ¶ÔÏóµÄÐòÁл¯¡£ÆäʵSerializable½Ó¿ÚÖв¢Ã»ÓÐÐèҪʵÏֵķ½·¨£¬×¢Ã÷ij¸öÀàimplements SerializableÖ»ÊÇΪÁ˱êʶ»ò±íÃ÷Õâ¸öÀà¿ÉÒÔ±»ÐòÁл¯¡£
ÄÇôʲôÊÇÐòÁл¯ÄØ£¬ÐòÁл¯ÓÖÓÐʲô×÷ÓÃÄØ£¿
Ò»¸öÀ࣬»ò ......