SP返回XML [英] SP returning XML

查看:81
本文介绍了SP返回XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能举例说明如何使用返回XML数据的

存储过程吗?


我想从VBScript调用SP程序,

并将XML放入生成的HTML中的数据岛。

Can someone give me an example of how to use a
stored procedure that returns XML data?

I want to call the SP from a VBScript program,
and put the XML into a data island in the generated HTML.

推荐答案

Peter Morris写道:
Peter Morris wrote:
有人能举例说明如何使用返回XML数据的存储过程吗?

我想从VBScript程序中调用SP,并将XML放入生成的HTML中的数据岛中。
Can someone give me an example of how to use a
stored procedure that returns XML data?

I want to call the SP from a VBScript program,
and put the XML into a data island in the generated HTML.




您是指运行包含FOR XML子句的查询的过程吗?


Bob Barrows


-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。这个电子邮件帐户是我的垃圾邮件陷阱所以我

不经常检查它。如果您必须离线回复,请删除

无垃圾邮件



Do you mean a procedure that runs a query containing a FOR XML clause?

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don''t check it very often. If you must reply off-line, then remove the
"NO SPAM"




" Bob巴罗斯[MVP]" <再****** @ NOyahoo.SPAMcom>在消息中写道

news:%2 **************** @ TK2MSFTNGP10.phx.gbl ...

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Peter Morris写道:
Peter Morris wrote:
有人能举例说明如何使用返回XML数据的存储过程吗?

我想从VBScript程序中调用SP ,
并将XML放入生成的HTML中的数据岛中。
Can someone give me an example of how to use a
stored procedure that returns XML data?

I want to call the SP from a VBScript program,
and put the XML into a data island in the generated HTML.



是指运行包含FOR XML子句的查询的过程?

Bob Barrows



Do you mean a procedure that runs a query containing a FOR XML clause?

Bob Barrows




是的,我的SP有FOR XML AUTO,ELEMENTS。它以XML格式返回结果




现在,我有一个动态生成HTML

输出的VBscript程序。我想从VBScript运行我的SP,并在我的HTML中将XML作为

a数据岛插入。



Yes, my SP has FOR XML AUTO, ELEMENTS. It returns the results
as XML.

Now, I have a VBscript program that dynamically generates HTML
output. I want to run my SP from VBScript, and insert the XML as
a data island in my HTML.


Peter Morris写道:
Peter Morris wrote:
Bob Barrows [MVP]" <再****** @ NOyahoo.SPAMcom>在消息中写道
新闻:%2 **************** @ TK2MSFTNGP10.phx.gbl ...
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Peter Morris写道:
Peter Morris wrote:
有人能举例说明如何使用返回XML数据的存储过程吗?

我想从VBScript程序中调用SP,并将XML放入生成的HTML中的数据岛中。
Can someone give me an example of how to use a
stored procedure that returns XML data?

I want to call the SP from a VBScript program,
and put the XML into a data island in the generated HTML.



是指运行包含FOR XML
子句的查询的过程? Bob Barrows



Do you mean a procedure that runs a query containing a FOR XML
clause? Bob Barrows



是的,我的SP有FOR XML AUTO,ELEMENTS。它将结果作为XML返回。

现在,我有一个动态生成HTML
输出的VBscript程序。我想从VBScript运行我的SP,并在我的HTML中将XML作为数据岛插入。



Yes, my SP has FOR XML AUTO, ELEMENTS. It returns the results
as XML.

Now, I have a VBscript program that dynamically generates HTML
output. I want to run my SP from VBScript, and insert the XML as
a data island in my HTML.



我有一些使用Stream来获取数据的代码。让我找一下

吧:......啊!这是:


<%@ Language = VBScript%>

<%

选项显式

dim cn,rs,sQuery,cmd,xmldoc

Const adExecuteStream =& H00000400

Const adCmdText =& H0001

set cn = server.CreateObject(" adodb.connection")

cn.open" provider = sqloledb; data source = ????;" &安培; _

" user id = ???; password = ????; initial catalog = northwind"

设置xmldoc = server.createobject(" msxml2.domdocument")

设置cmd = Server.CreateObject(" ; ADODB.Command")

设置cmd.ActiveConnection = cn

sQuery =" SELECT * FROM PRODUCTS ORDER BY PRODUCTNAME FOR XML auto"

cmd.CommandText = sQuery

cmd.Properties(" xml root")。Value =" root"

cmd.Properties(" Output Stream")= xmldoc

cmd.Execute ,, adExecuteStream + adCmdText

set cmd = nothing

cn.close

set cn =没有

%>

< html>

....

< XML id = " xmlData">

<%= xmldoc.xml%>

< / XML>

< / html>


HTH,

Bob Barrows

-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。这个电子邮件帐户是我的垃圾邮件陷阱所以我

不经常检查它。如果您必须离线回复,请删除

无垃圾邮件


I have some code somewhere that uses a Stream to get te XML. Let me look for
it: ... ah! Here it is:

<%@ Language=VBScript %>
<%
option explicit
dim cn, rs,sQuery, cmd, xmldoc
Const adExecuteStream = &H00000400
Const adCmdText = &H0001
set cn=server.CreateObject("adodb.connection")
cn.open "provider=sqloledb;data source=????;" & _
"user id = ???; password=????;initial catalog=northwind"
Set xmldoc=server.createobject("msxml2.domdocument")
Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = cn
sQuery = "SELECT * FROM PRODUCTS ORDER BY PRODUCTNAME FOR XML auto"
cmd.CommandText = sQuery
cmd.Properties("xml root").Value = "root"
cmd.Properties("Output Stream") = xmldoc
cmd.Execute , , adExecuteStream + adCmdText
set cmd=nothing
cn.close
set cn=nothing
%>
<html>
....
<XML id="xmlData">
<%=xmldoc.xml%>
</XML>
</html>

HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don''t check it very often. If you must reply off-line, then remove the
"NO SPAM"


这篇关于SP返回XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆