Êý¾Ý¿â²éѯXML½á¹¹£¬FOR XML PATH Óï¾äµÄÓ¦ÓÃ
/*
Êý¾Ý¿â²éѯXML½á¹¹£¬FOR XML PATH Óï¾äµÄÓ¦ÓÃ
*/
FOR XML PATH Óï¾äµÄÓ¦ÓÃ:
CREATE TABLE TempTable(UserID int , UserName nvarchar(50));
insert into TempTable (UserID,UserName) values (1,'a')
insert into TempTable (UserID,UserName) values (2,'b')
select UserID,UserName from TempTable FOR XML PATH
-----ÔËÐÐÕâ¶Î½Å±¾£¬½«Éú³ÉÈçϽá¹û£º
<row>
<UserID>1</UserID>
<UserName>a</UserName>
</row>
<row>
<UserID>2</UserID>
<UserName>b</UserName>
</row>
----´ó¼Ò¿ÉÒÔ¿´µ½Á½ÐÐÊý¾ÝÉú³ÉÁËÁ½¸ö½Úµã£¬ÐÞ¸ÄÒ»ÏÂPATHµÄ²ÎÊý£º
select UserID,UserName from TempTable FOR XML PATH('lzy')
----ÔÙ´ÎÔËÐÐÉÏÊö½Å±¾£¬½«Éú³ÉÈçϵĽá¹û£º
<lzy>
<UserID>1</UserID>
<UserName>a</UserName>
</lzy>
<lzy>
<UserID>2</UserID>
<UserName>b</UserName>
</lzy>
----¿ÉÒÔ¿´µ½½Úµã±ä³É£¬ÆäʵPATH() À¨ºÅÄڵIJÎÊýÊÇ¿ØÖƽڵãÃû³ÆµÄ£¬ÕâÑùµÄ»°´ó¼Ò¿ÉÒÔ¿´Ò»ÏÂÈç¹ûÊÇ¿Õ×Ö·û´®£¨²»ÊÇûÓвÎÊý£©»áÊÇʲô½á¹û?
select UserID,UserName from TempTable FOR XML PATH('')
----Ö´ÐÐÉÏÃæÕâ¶Î½Å±¾½«Éú³É½á¹û£º
<UserID>1</UserID>
<UserName>a</UserName>
<UserID>2</UserID>
<UserName>b</UserName>
---ÕâÑù¾Í²»ÏÔʾÉϼ¶½ÚµãÁË£¬
---´ó¼ÒÖªµÀÔÚ PATH ģʽÖУ¬ÁÐÃû»òÁбðÃû±»×÷Ϊ XPath ±í´ïʽÀ´´¦Àí£¬
---Ò²¾ÍÊÇ˵£¬ÊÇÁеÄÃû×Ö£¬ÕâÑù´óµ¨ÊÔÑéһϲ»¸øÖ¸¶¨ÁÐÃûºÍ±ðÃû»áÊÇÔõôÑù£¿
select cast(userid as varchar) +','+ username from TempTable for xml path('')
select CAST(UserID AS varchar) + '',UserName + '' from TempTable FOR XML PATH('')
---ÔËÐÐÉÏÃæÕâ¾ä½«Éú³É½á¹û
----1a2b
----ËùÓÐÊý¾Ý¶¼Éú³ÉÒ»ÐУ¬¶øÇÒ»¹Ã»ÓÐÁ¬½Ó×Ö·û£¬ÕâÑùµÄÊý¾Ý¿ÉÄܶԴó¼ÒûÓÐÓô¦£¬»¹¿ÉÒÔÔٱ仯һÏ£º
select CAST(UserID AS varchar) + ',',UserName + '',';' from TempTable FOR XML PATH('')
select CAST(userid as varchar) +',' +username +';' from TempTable for xml path('')
----Éú³É½á¹û
1,a;2,b;
----´ó¼ÒÏÖÔÚÃ÷°×ÁË°É£¬¿ÉÒÔͨ¹ý¿ØÖƲÎÊýÀ´Éú³É×Ô¼ºÏëÒªµÄ½á¹û£¬ÀýÈ磺
select '{' + CAST(UserID A
Ïà¹ØÎĵµ£º
д±¾ÎĵÄÄ¿µÄÊÇΪÁË·½±ã´ó¼ÒÁ˽âC++ MSXML²Ù×÷·½·¨¡£
µ±È»£¬C++ÖжÔMSXMLµÄµ÷ÓÃÓжàÖÖ£¬±¾ÎIJÉÓõķ½·¨ÊÇÍêÈ«²ÎÕÕMSXML SDKÌṩµÄÎĵµ½øÐвÙ×÷¡£
Èç¹ûÓÐʲô´íÎ󣬻¶ÓÖ¸Õý¡£
´úÂë¿ò¼ÜÊÇ»ùÓÚvs2008 MFC ¶Ô»°¿ò³ÌÐò£¨UNICODE£©¡£¶Ô»°¿ò³ÌÐòÐèÒª¶ÁÕß×Ô¼º´´½¨¡£
#include <msxml6.h>
#include <comutil.h>
# ......
Internet µÄÓ¦ÓÃÕýÔÚ²»¶ÏµØÀ©´ó£¬µ«ÎÒÃÇµÄ Internet ±à³Ì·½Ê½»¹´¦ÓÚʯÆ÷ʱ´ú¡£Internet Óû§¾ÍÏñÀÏʽÖ÷»úµÄ·ÖʱÖÕ¶ËÉϵÄÓû§Ò»Ñù£¬ËûÃÇ´ÓÒ»¸öÊܱ£»¤µÄ×ÊÔ´ÇëÇóÐÅÏ¢£¬È»ºóµÈ´ý»ØÓ¦¡£Äã´ÓÕýÔÚä¯ÀÀµÄ Internet Õ¾µãÉϽÓÊÕµÄÐÅÏ¢ÓÉËüÏ£ÍûÌṩ¸øÄãµÄ¡¢»ùÓÚ HTML µÄÐÅÏ¢×é³ÉµÄ¡£
¡¡¡¡µ«ÊÇ£¬Í¬Ô¶³Ì Web Õ¾µã½øÐн»»¥Ê½²Ù×÷ÊDz»ÊÇ ......
·Ò룺Çï·ã
Ô´úÂ룺
LoadingXmlInTvMTCode.zip
ÔںܶàÇé¿öϳÌÐòÔ±ÐèÒª²ÉÓöàÏß³ÌÀ´¿ª·¢Ó¦ÓóÌÐò£¬Óû§¿ÉÒÔÔÚǰ̨²Ù×÷Êý¾Ý»òÆäËû¹¤×÷£¬ÔÚºǫ́³ÌÐòÕýÔÚ¼ÓÔغܴóµÄһЩÎļþ£¬¶øÕâÒ»¹ý³Ì²»»áÓ°Ï쵽ǰ̨µÄÓû§¡£ÔÚÕâƪÎÄÕÂÖУ¬ÎÒÀ´½²ÊöÒ»ÏÂÔõÑùͨ¹ý¶à¸öÏß³ÌÀ´¼ÓÔضà¸öÎļþ¡£
ÔÚÕâ¸öÀý×ÓÖÐÎÒÃǽ«À´Ñо¿Õ ......
Ê×ÏÈÒªÓÐÒ»¸ö¼òÒ׵ķþÎñÆ÷£¬½¨Á¢Ò»¸öÕ¾µã£¬È»ºóÕ¾µãÏ´æ·Å
1£ºcrossdomain.xml Õâ¸öÊÇ¿çÓëÓò²ßÂÔÎļþ£¬ÓÃÓÚÖ¸¶¨Óòͨ¹ýFlash
Player·ÃÎʱ¾ÓòµÄ×ÊÔ´(Èç¹û·þÎñÆ÷ÔÚ±¾»ú¾ÍûÓÐÕâ¸ö±ØÒª)µ«ÊÇÔ¶³ÌµÄ»°¾ÍÒª(½¨ÒéÒª)
ÎļþÄÚÈÝ£º
<cross-domain-policy>
<allow-access-from domain="*" /> ......
¡¡¡¡DTDʵ¼ÊÉÏ¿ÉÒÔ¿´×÷Ò»¸ö»ò¶à¸öXMLÎļþµÄÄ£°å£¬ÕâЩXMLÎļþÖеÄÔªËØ¡¢ÔªËصÄÊôÐÔ¡¢ÔªËصÄÅÅÁз½Ê½/˳Ðò¡¢ÔªËØÄܹ»°üº¬µÄÄÚÈݵȣ¬¶¼±ØÐë·ûºÏDTDÖеĶ¨Òå¡£XMLÎļþÖеÄÔªËØ£¬¼´ÎÒÃÇËù´´½¨µÄ±ê¼Ç£¬ÊǸù¾ÝÎÒÃÇÓ¦ÓõÄʵ¼ÊÇé¿öÀ´´´½¨µÄ¡£ÏëÒª´´½¨Ò»·ÝÍêÕûÐԸߡ¢ÊÊÓ¦ÐÔ¹ãµÄDTDÊǷdz£À§Äѵģ¬ÒòΪ¸÷Ðи÷Òµ¶¼ÓÐËûÃÇ×Ô¼ºµÄÐÐÒµÌص㣠......