½«±í»ò²éѯ´æ´¢Îª±ê×¼µÄXMLÎļþ
/*--´æΪXML
½«±í/²éѯ´æ´¢Îª±ê×¼µÄXMLÎļþ
--*/
/*--µ÷ÓÃʾÀý
--ÓÃSQLÓÃwinowsÉí·ÝÑéÖ¤µÄÇé¿ö
exec p_savexml @sql='µØÇø×ÊÁÏ',@fname='c:\µØÇø×ÊÁÏ.xml'
--ÓÃÖ¸¶¨µÄÓû§
exec p_savexml @sql='µØÇø×ÊÁÏ',@fname='c:\µØÇø×ÊÁÏ.xml',@userid='sa'
--*/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[p_savexml]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[p_savexml]
GO
create proc p_savexml
@sql varchar(8000), --Òª±£´æµÄ±í/ÊÓͼ/SQL²éѯÓï¾ä
@fname varchar(1000)='c:\tmp.xml', --±£´æµÄXMLÎļþÃû
@userid varchar(50)='', --Óû§Ãû,Èç¹ûΪntÑéÖ¤·½Ê½,ÔòΪ''
@password varchar(50)='' --ÃÜÂë
as
declare @err int,@src varchar(255),@desc varchar(255)
declare @obj int,@constr varchar(1000)
if isnull(@userid,'')=''
set @constr='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog='
+db_name()+';Data Source='+@@servername
else
set @constr='Provider=SQLOLEDB.1;Persist Security Info=True;'
+'User ID='+@userid+';Password='+isnull(@password,'')
+';Initial Catalog='+db_name()+';Data Source='+@@servername
exec @err=sp_oacreate 'adodb.recordset',@obj out
if @err<>0 goto lberr
exec @err=sp_oamethod @obj,'open',null,@sql,@constr
if @err<>0 goto lberr
set @sql='del '+@fname
exec master..xp_cmdshell @sql,no_output
exec @err=sp_oamethod @obj,'save',null,@fname,1
if @err<>0 goto lberr
exec @err=sp_oadestroy @obj
return
lberr:
exec sp_oageterrorinfo 0,@src out,@desc out
select cast(@err as varbinary(4)) as ´íÎóºÅ
,@src as ´íÎóÔ´,@desc as ´íÎóÃèÊö
go
Ïà¹ØÎĵµ£º
Ê×ÏÈдһ¸öhtmlÒ³Ãæuserxmlajax.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Óû§Ð£ÑéajaxʵÀý</title>
&nbs ......
Ê×ÏÈдһ¸öhtml userxmljquery.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Óû§Ð£ÑéajaxʵÀý</title>
& ......
¡¡¡¡ÔÚÉÏһƪÎÄÕÂÖУ¬ÎÒÃÇÌÖÂÛÁËÈçºÎͨ¹ýjavascript´ÓÒ»¸öÔ¶³ÌXMLÎļþÖÐÈ¡µÃÊý¾Ý¡£ÔÚÕâƪÎÄÕÂÖУ¬ÎÒÃǽ«Ñ§»áÔõÑù¶ÔÊý¾Ý×÷¸ü¸´ÔӵĴ¦Àí¡£×÷Ϊһ¸öʾÀý£¬ÎÒÃÇ»á×¼±¸Ò»×éXMLÊý¾Ý£¬½«Êý¾Ý·Ö¸î³É¶ÀÁ¢µÄƬ¶Ï²¢ÒÔ²»Í¬µÄ·½Ê½Õ¹Ê¾ÕâЩƬ¶Ï£¨È¡¾öÓÚËüÃÇÊÇÈçºÎ±»±êʶµÄ£©¡£
¡¡¡¡ÕâƪÎÄÕÂÊǽ¨Á¢ÔÚÉÏһƪÎÄÕÂÖй¹ÔìµÄʾÀý´úÂëµÄ»ù´¡Ö®ÉÏ ......
½â¾öÁË£¬ÊÇ1¥˵µÄ·½·¨£¬²»ÄÜд³É
context.Response.ContentType = "xml";
±ØÐëÒªÊÇ
context.Response.ContentType = "text/xml";
¾ÍOKÁË¡«
ʵÀý£º
Response.ContentType = "text/xml";
Page.Response.Write("<?xml version=\"1.0\" ......
ת×Ô£ºhttp://www.w3school.com.cn/xml/xml_dtd.asp
ÓµÓÐÕýÈ·Óï·¨µÄ XML ±»³ÆΪ“ÐÎʽÁ¼ºÃ”µÄ XML¡£
ͨ¹ýij¸ö DTD ½øÐÐÁËÑéÖ¤µÄ XML ÊÇ“ºÏ·¨”µÄ XML¡£
ÐÎʽÁ¼ºÃµÄ XML Îĵµ
Ò»¸ö"ÐÎʽÁ¼ºÃ"µÄ XML ÎĵµÓµÓÐÕýÈ·µÄÓï·¨¡£
Ò»¸ö"ÐÎʽÁ¼ºÃ"µÄ XML Îĵµ»á×ñÊØÇ°¼¸Õ½éÉܹýµÄ XML Óï·¨¹æÔò£º
XML 뀵 ......