ASP±éÀúXML½Úµã
±éÀúXMLÎĵµ
¶ÔÓÚÏÂÃæµÄÒ»¶ÎXML´úÂ룺
XMLÎĵµÊµÀýbooks.xml£¬ÈçÏÂËùʾ£º
<?xml version="1.0" encoding="gb2312" ?>
<books>
<book status="ÒÑÊÛÍê">
<author>ÆÆÆÆ</author>
<title>XMLÈëÃÅ</title >
</book>
<book status="ÈÈÂôÖÐ">
<author>»µ»µ</author>
<title>XMLÌá¸ß</title>
</book>
</books>
ÎÒÃÇÒѾ¿ÉÒÔ´´½¨XMLÎĵµ¶ÔÏ󣬲¢¼ÓÔØXMLÎĵµÁË¡£¶ÔÓÚÒѾ¼ÓÔصÄÎĵµ£¬ÎÒÃÇÒª´ÓÎĵµÖлñÈ¡ËùÐèÒªµÄÄÚÈÝ£¬Õâ¾ÍÒªÇóÄܹ»Í¨¹ýDOMÊ÷À´·ÃÎÊÊ÷ÖеÄÈκÎÒ»¸ö½Úµã£¬Ò²¾ÍÊǶÔDOMÊ÷µÄ±éÀú¡£
ÏÂÃæÎÒÃÇÒÀ¾ÉÒÔbooks.xmlΪÀý£¬Í¨¹ý¼¸¸öʵÀýÀ´ËµÃ÷ÈçºÎ±éÀúDOMÊ÷ÖеĽڵ㡣
Ê×ÏÈ£¬ÎÒÃÇÒª»ñÈ¡XMLÎĵµµÄ¸ùÔªËؽڵ㣬ÓÃVBÃèÊöÕâ¸ö²Ù×÷ÈçÏ£º
Set root = myDocument.documentElement
ÏÖÔÚ£¬ÎÒÃÇÒѾµÃµ½ÁËÎĵµµÄ¸ùÔªËؽڵ㣬¶ÔÓÚÆäËûÔªËØ£¬ÎÒÃÇÈçºÎ»ñµÃ¶ÔËüµÄ·ÃÎÊÄØ£¿ÒÔÎĵµÖеĵڶþ¸öbookÔªËØΪÀý£¬¶Ô¸ÃÔªËؽڵãÒÔ¼°Æä×Ó½ÚµãµÄ·ÃÎÊ¿ÉÒÔͨ¹ýÏÂÃæµÄ·½Ê½À´ÊµÏÖ¡£
Set bookNode = root.childNodes.item(1)
Set authorNode = bookNode.childNodes.item(0)
Set textNode = authorNode.childNodes.item(0)
Set theName = textNode.nodeValue
ÉÏÊö·ÃÎÊÓï¾äÖ´Ðкó£¬theNameµÄÖµÊÇ"»µ»µ"¡£
ÔÚÉÏÃæµÄ´úÂëÖУ¬rootÊÇÎĵµµÄ¸ùÔªËؽڵãbooks½Úµã£¬bookNodeºÍauthorNode¶¼ÊÇÔªËØÀàÐ͵Ľڵ㣬textNodeÊÇTEXTÀàÐ͵Ľڵ㣬theNameÊÇÒ»¸ö×Ö·û´®¡£
childNodesÊÇNodeListÀàÐ͵ÄÊôÐÔ£¬itemÊÇNodeList½Ó¿ÚÖÐNodeÀàÐ͵ÄÊôÐÔ£¬Í¨¹ýitem¿ÉÒÔ·ÃÎÊNodeList
½Úµã¼¯ºÏÖеÄÈÎÒâ½Úµã£¨Õâ¶ùÓÐÒ»µãÐèҪעÒ⣬µ±ÎÒÃÇÒª·ÃÎʸùÔªËؽڵãbooksµÄµÚ¶þ¸öbook×Ó½ÚµãbookNodeʱ£¬ÎÒÃÇÓõÄË÷Òý²ÎÊýÊÇ"1"£¬Õâ
ÊÇÒòΪitemÖеÄË÷Òý²ÎÊýÊÇ´Ó0¿ªÊ¼µÄ£¬Èç¹ûÎÒÃÇÒª·ÃÎʽڵ㼯ºÏÖеĵÚÒ»¸ö½Úµã£¬ÔòÓ¦¸ÃÓÃitem(0)À´±íʾ£©¡£
ÔÚDOM¹æ·¶ÖУ¬Òª·ÃÎÊÔªËؽڵãµÄÎı¾ÄÚÈÝ£¬ÐèÒªÏȵõ½ÔªËؽڵãµÄTEXT×ӽڵ㣬ÔÙͨ¹ýTEXT½ÚµãµÄÊôÐÔ»ñÈ¡Îı¾ÄÚÈÝ¡£Î¢ÈíÔÚʵÏÖDOM½Ó¿Úʱ
¶ÔDOM½øÐÐÁ˲¿·ÖÀ©Õ¹£¬¿ÉÒÔͨ¹ýÔªËØÀàÐͽڵãµÄtextÊôÐÔÖ±½Ó»ñµÃÔªËØÖеÄÎı¾ÄÚÈÝ¡£¾ßÌåʵÓÃ˵Ã÷¿ÉÒԲο¼Î¢ÈímsdnÖеİïÖú¡£
ÉÏÃæµÄÀý×Ó¸ø³öÁËÈçºÎ·ÃÎÊDOMÊ÷ÖеÄÔªËؽڵ㣬¶ÔÓÚDOMÊ÷ÖеÄÊôÐԽڵ㣬·ÃÎÊ·½·¨ÂÔÓв»Í¬£¬¿ÉÒÔͨ¹ýÏÂÃæµÄÓï¾äÀ´ÊµÏÖ£º
Set bookNode = root.chil
Ïà¹ØÎĵµ£º
ÔÎĵØÖ·£ºhttp://bbs.bccn.net/thread-225295-1-1.html
¡¡¡¡Èç¹û»ú·¿ÂíÉÏÒª¹ØÃÅÁË£¬»òÕßÄã¼±×ÅÒªºÍMMÔ¼»á£¬ÇëÖ±½ÓÌøµ½µÚËĸö×ÔÈ»¶Î¡£
¡¡¡¡ÒÔÏÂÐðÊöµÄ½Å±¾°üÀ¨·þÎñÆ÷¶Ë½Å±¾ºÍ¿Í»§¶ËµÄ½Å±¾£¬·þÎñÆ÷¶Ë½Å±¾Ö¸ÔÚ·þÎñÆ÷ÉÏÔËÐеÄÄDz¿·Ö½Å±¾£¬±ÈÈç³£¼ûµÄResponse.WriteÏÔÈ»ÊÇÔÚ·þÎñÆ÷ÉÏÔËÐеģ¬·þÎñÆ÷¶Ë½Å±¾¿ÉÒÔʹÓÃVBScriptºÍJS ......
´ËÎÄÖ»ÊÇÈëÃÅ£¬ÑÝʾÁËÈçºÎÓÃʵÌåÀà´æ´¢Êý¾Ý£¬ÎÞʵ¼ÊÒâÒå¡£ºóÃæÓнÐø¸üÐÂÓÅ»¯¡££¨ÒÔºóµÄÎÄÕÂÖн«Â½ÐøʵÏÖÎÞÐèÉùÃ÷¾ßÌåÀà×Ô¶¯´æ´¢Êý¾Ý£¬ºÍ¼òµ¥µÄÐÔÄÜÓÅ»¯£©
ÔÚasp³ÌÐò¿ª·¢¹ý³ÌÖУ¬½á¹¹Êý¾ÝµÄ´æ´¢Ò»Ö±ÊǸöÎÊÌ⣬aspµÄÊý×éÒ»Ö±ºÜÈõ£¬¶øÇÒ²»ÄÜ×Ô½âÊÍ£¬ ......
ÔÚJ2MEÌåϵÖУ¬¶ÔxmlµÄ½âÎöÓбȽÏÓÐÃûµÄµÚÈý·½½âÎöAPI£¬·Ö±ðΪKXMLºÍNanoXML£¬ËûÃǶ¼ÌṩÁ˶ԽâÎöxmlµÄÖ§³Ö¡£KXMLÔÚ½âÎöXML¹ý³ÌÖлá¶ÔÎļþÄÚÈÝÒ»²ãÒ»²ã½øÐнâÎö£¬Òò´Ë³ÉΪÔöÁ¿Ê½½âÎöÆ÷£¬±È½ÏÊʺϴóÎļþµÄ½âÎö¡£¶øNanoXMLÊÇÒ»´ÎÐÔ½âÎöÆ÷£¬ÔÚÒ»´Îʱ¼äÀï¾Í°ÑÕû¸öxmlÎĵµ½âÎöÍ꣬Òò´Ë²»ÊʺϴóÎļþµÄ½âÎö£¬»áÔì³ÉÄÚ´æ²»×ãµÄÏÖÏó¡ ......
¡¡¡¡×î½üÓкܶàµÄÅóÓÑÎʵ½µ÷Óô洢¹ý³ÌµÄÎÊÌ⣬ÕâÀï¼òµ¥½éÉܼ¸ÖÖASPµ÷Óôø²ÎÊý´æ´¢¹ý³ÌµÄ·½·¨¡£
¡¡¡¡1. ÕâÒ²ÊÇ×î¼òµ¥µÄ·½·¨,Á½¸öÊäÈë²ÎÊý£¬ÎÞ·µ»ØÖµ£º
¡¡¡¡set connection = server.createobject("adodb.connection")
¡¡¡¡connection.open someDSN
¡¡¡¡Connection.Execute "procname varvalue1, varvalue2"
¡¡¡¡'½«Ëù ......