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
Ïà¹ØÎĵµ£º
ÔÚÏîÄ¿ÖУ¬ÎÒÃǺܶ඼Óõ½ÁËxmlÎļþ£¬ÎÞÂÛÊDzÎÊýÅäÖû¹ÊÇÓëÆäËüϵͳµÄÊý¾Ý½»»¥¡£
½ñÌì¾ÍÀ´½²Ò»ÏÂJava ÖÐʹÓÃdom4jÀ´²Ù×÷XMLÎļþ¡£
ÎÒÃÇÐèÒªÒýÈëµÄ°ü£º
//Îļþ°ü
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileWriter;
//¹¤¾ß°ü
import java.util.Ite ......
½ñÌì¶ÔXMLÎļþ½øÐÐÁËһЩ¼òµ¥µÄ¶Áд²Ù×÷£¬ÏÂÃæÀ´¾ßÌåʵÏÖ²½Ö裺
Ê×ÏÈ£º½¨Á¢Ò»¸ö»ùÓÚDialogµÄMFC¹¤³Ì£¬¹¤³ÌÃûΪOperateXML£¬È»ºóÔÚ¶Ô»°¿òÉÏÌí¼ÓÁ½¸ö°´Å¥("Create"ºÍ"GetData"ºÍÒ»¸öListControl
¿Ø¼þ(ÓÃÀ´ÏÔʾÊý¾Ý)£¬Ê×ÏÈÒªµ¼Èë¿âÎļþ
#import "msxml3.dll"
using namespace MSXML2;
Ö÷ÒªÓÃÀ´ÊµÏÖXMLÎļþµÄÏà¹Ø²Ù×÷£¬
......
¡¡¡¡1. Ö»·µ»Øµ¥Ò»¼Ç¼¼¯µÄ´æ´¢¹ý³Ì
¡¡¡¡¼ÙÉèÓÐÒÔÏ´洢¹ý³Ì(±¾ÎĵÄÄ¿µÄ²»ÔÚÓÚ½²ÊöT-SQLÓï·¨£¬ËùÒÔ´æ´¢¹ý³ÌÖ»¸ø³ö´úÂ룬²»×÷˵Ã÷)£º
/*SP1*/
CREATE PROCEDURE dbo.getUserList
as
set nocount on
begin
select * from dbo.[userinfo]
end
go
¡¡¡¡ÒÔÉÏ´æ´¢¹ý³ÌÈ¡µÃuserinfo±íÖеÄËùÓмǼ£¬·µ»ØÒ»¸ö¼Ç¼¼¯¡£Í¨¹ ......