JavaµÄXMLÎļþ²Ù×÷Ö®DOMÈëÃÅƪ £¨2£©
ÏÂÃæµÄÄÚÈÝ£¬ÎÒÃǽ«¸ü¶àµÄ¹Ø×¢DOM£¬ÎªDOM×÷Ò»¸ö½ÏΪÏêϸµÄ½âÎö£¬Ê¹ÎÒÃÇʹÓÃÆðÀ´¸üΪµÃÐÄÓ¦ÊÖ¡£
DOMÏê½â
1£®»ù±¾µÄDOM¶ÔÏó
DOMµÄ»ù±¾¶ÔÏóÓÐ5¸ö£ºDocument£¬Node£¬NodeList£¬ElementºÍAttr¡£ÏÂÃæ¾ÍÕâЩ¶ÔÏóµÄ¹¦ÄܺÍʵÏֵķ½·¨×÷Ò»¸ö´óÖµĽéÉÜ¡£
Document¶ÔÏó´ú±íÁËÕû¸öXMLµÄÎĵµ£¬ËùÓÐÆäËüµÄNode£¬¶¼ÒÔÒ»¶¨µÄ˳Ðò°üº¬ÔÚDocument¶ÔÏóÖ®ÄÚ£¬ÅÅÁгÉÒ»¸öÊ÷ÐεĽṹ£¬³ÌÐòÔ±¿ÉÒÔͨ¹ý±éÀúÕâ¿ÅÊ÷À´µÃµ½XMLÎĵµµÄËùÓеÄÄÚÈÝ£¬ÕâÒ²ÊǶÔXMLÎĵµ²Ù×÷µÄÆðµã¡£ÎÒÃÇ×ÜÊÇÏÈͨ¹ý½âÎöXMLÔ´Îļþ¶øµÃµ½Ò»¸öDocument¶ÔÏó£¬È»ºóÔÙÀ´Ö´ÐкóÐøµÄ²Ù×÷¡£´ËÍ⣬Document»¹°üº¬ÁË´´½¨ÆäËü½ÚµãµÄ·½·¨£¬±ÈÈçcreateAttribut()ÓÃÀ´´´½¨Ò»¸öAttr¶ÔÏó¡£ËüËù°üº¬µÄÖ÷ÒªµÄ·½·¨ÓУº
createAttribute(String)£ºÓøø¶¨µÄÊôÐÔÃû´´½¨Ò»¸öAttr¶ÔÏ󣬲¢¿ÉÔÚÆäºóʹÓÃsetAttributeNode·½·¨À´·ÅÖÃÔÚijһ¸öElement¶ÔÏóÉÏÃæ¡£
createElement(String)£ºÓøø¶¨µÄ±êÇ©Ãû´´½¨Ò»¸öElement¶ÔÏ󣬴ú±íXMLÎĵµÖеÄÒ»¸ö±êÇ©£¬È»ºó¾Í¿ÉÒÔÔÚÕâ¸öElement¶ÔÏóÉÏÌí¼ÓÊôÐÔ»ò½øÐÐÆäËüµÄ²Ù×÷¡£
createTextNode(String)£ºÓøø¶¨µÄ×Ö·û´®´´½¨Ò»¸öText¶ÔÏó£¬Text¶ÔÏó´ú±íÁ˱êÇ©»òÕßÊôÐÔÖÐËù°üº¬µÄ´¿Îı¾×Ö·û´®¡£Èç¹ûÔÚÒ»¸ö±êÇ©ÄÚûÓÐÆäËüµÄ±êÇ©£¬ÄÇô±êÇ©ÄÚµÄÎı¾Ëù´ú±íµÄText¶ÔÏóÊÇÕâ¸öElement¶ÔÏóµÄΨһ×Ó¶ÔÏó¡£
getElementsByTagName(String)£º·µ»ØÒ»¸öNodeList¶ÔÏó£¬Ëü°üº¬ÁËËùÓиø¶¨±êÇ©Ãû×ֵıêÇ©¡£
getDocumentElement()£º·µ»ØÒ»¸ö´ú±íÕâ¸öDOMÊ÷µÄ¸ù½ÚµãµÄElement¶ÔÏó£¬Ò²¾ÍÊÇ´ú±íXMLÎĵµ¸ùÔªËصÄÄǸö¶ÔÏó¡£
Node¶ÔÏóÊÇDOM½á¹¹ÖÐ×îΪ»ù±¾µÄ¶ÔÏ󣬴ú±íÁËÎĵµÊ÷ÖеÄÒ»¸ö³éÏóµÄ½Úµã¡£ÔÚʵ¼ÊʹÓõÄʱºò£¬ºÜÉÙ»áÕæÕýµÄÓõ½NodeÕâ¸ö¶ÔÏ󣬶øÊÇÓõ½ÖîÈçElement¡¢Attr¡¢TextµÈNode¶ÔÏóµÄ×Ó¶ÔÏóÀ´²Ù×÷Îĵµ¡£Node¶ÔÏóΪÕâЩ¶ÔÏóÌṩÁËÒ»¸ö³éÏóµÄ¡¢¹«¹²µÄ¸ù¡£ËäÈ»ÔÚNode¶ÔÏóÖж¨ÒåÁ˶ÔÆä×Ó½Úµã½øÐдæÈ¡µÄ·½·¨£¬µ«ÊÇÓÐһЩNode×Ó¶ÔÏ󣬱ÈÈçText¶ÔÏó£¬Ëü²¢²»´æÔÚ×ӽڵ㣬ÕâÒ»µãÊÇҪעÒâµÄ¡£Node¶ÔÏóËù°üº¬µÄÖ÷ÒªµÄ·½·¨ÓУº
appendChild(org.w3c.dom.Node)£ºÎªÕâ¸ö½ÚµãÌí¼ÓÒ»¸ö×ӽڵ㣬²¢·ÅÔÚËùÓÐ×Ó½ÚµãµÄ×îºó£¬Èç¹ûÕâ¸ö×Ó½ÚµãÒѾ´æÔÚ£¬ÔòÏÈ°ÑËüɾµôÔÙÌí¼Ó½øÈ¥¡£
getFirstChild()£ºÈç¹û½Úµã´æÔÚ×ӽڵ㣬Ôò·µ»ØµÚÒ»¸ö×ӽڵ㣬¶ÔµÈµÄ£¬»¹ÓÐgetLastChild()·½·¨·µ»Ø×îºóÒ»¸ö×ӽڵ㡣
getNextSibling()£º·µ»ØÔÚDOMÊ÷ÖÐÕâ¸ö½ÚµãµÄÏÂÒ»¸öÐֵܽڵ㣬¶ÔµÈµÄ£¬»¹ÓÐgetPreviousSibling()·½·¨·µ»ØÆäÇ°Ò»¸öÐֵܽڵ㡣
Ïà¹ØÎĵµ£º
±àÕß°´£º¶ÔJavaÉçÇøÀ´Ëµ,2009ÄêÊÇÒ»¸ö¶àÊÂÖ®Ä꣺OracleµÄÊÕ¹º´øÀ´Ï£Íûµ«¸ü¶àµÄÊǵ£ÓÇ£»¶ÔJava7µÄ½¹¼±µÈ´ý£»¶ÔÊÇ·ñÐèÒª±Õ°üµÄ³Ö
ÐøÕùÒ飻ÆäËûÊÕ¹º¶Ô¿ªÔ´ÉçÇøµÄÓ°Ïì±¾ÎÄÔ×÷ÕßJames SugrueÁªºÏJavaÉçÇøµÄÆäËûÈýλºËÐÄ¿ª·¢Õ߶Ô2009ÄêµÄJava½øÐÐÁËÅ̵㡣
James SugrueÊÇJavaLobbyºÍEclipseZoneµÄ±à¼£¬Ò»Î»Eclipse¿ª·¢Õߣ¬Jav ......
Java±à³ÌÄÇЩʶù
×÷Õߣº³ÂÔ¾·å¡¢ÀîÖбò¡¢¹ÈæçÓÂ
ͼÊéÏêϸÐÅÏ¢£º
ISBN£º9787302214052
¶¨¼Û£º39Ôª
Ó¡´Î£º1-1
×°Ö¡£ºÆ½×°
Ó¡Ë¢ÈÕÆÚ£º2009-12-30
ͼÊé¼ò½é£º
±¾ÊéÒÔͨË×Ò׶®µÄÓïÑԺʹúÂëʾÀý½éÉÜJavaÓïÑÔ±à³ÌµÄ¸÷ÖÖ֪ʶ£¬ÊÇÒ»±¾Ö¸µ¼³õѧÕß½øÐÐ×Ôѧ±à³Ì£¬²¢Í¨¹ýÏà¹ØÕ½ڸ½´øµÄÁ·Ï°ÈÚ»á¹áͨÏà¹Ø¼¼ÊõµÄÈëÃÅÊé¼®¡£ ......
µ±È»£¬Ê×ÏÈÒª°²×°ÓÐJDK(Ò»°ãÊÇJDK1.5.X)¡£È»ºó°²×°MySQL£¬ÕâЩ¶¼±È½Ï¼òµ¥£¬¾ßÌå¹ý³Ì¾Í²»ËµÁË¡£ÅäÖúÃÕâÁ½¸ö
»·¾³ºó£¬ÏÂÔØJDBCÇý¶¯mysql-connector-java-5.1.5.zip£¨http://www.ntu-w.lkams.kernel.org/pub/MySQL/Downloads/Connector-J/mysql-connector-java-5.1.5.zip£©¡£È»ºó½«Æä½âѹËõµ½ÈÎһĿ¼¡£ÎÒÊǽâѹµ½DÅÌ£¬È»ºó½ ......
ƽʱµÄ¿ª·¢µ±ÖУ¬Í¨³£ÎÒÃÇÐèÒªÑéÖ¤EmailµØÖ·µÄºÏ·¨ÐÔ£¬Ê×ÏÈÒªÔÚÑéÖ¤´ËµØÖ·ÊÇ·ñ·ûºÏ¹æ·¶£¬Èô·ûºÏ¹æ·¶£¬ÔÙ·¢ÓʼþÒÔÈ·Èϴ˵ØÖ·ÊÇ·ñ´æÔÚ¡£
Ô´ÂëÈçÏ£º
public static boolean validateEmail(String email){
//Pattern pattern = Pattern.compile("[0-9a-zA-Z]*.[0-9a-zA-Z]*@[a-zA-Z]*.[a-zA-Z]*", Pattern.LITE ......