日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

使用SQL Server连接xml接口,读取并解析数据

發布時間:2023/12/13 数据库 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用SQL Server连接xml接口,读取并解析数据 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

--數據源格式,放到任意程序中部署接口即可
--
<Data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> --<Peoples> --<People> --<Name>張三</Name> --<Sex>男</Sex> --</People> --<People> --<Name>李四</Name> --<Sex>女</Sex> --</People> --<People> --<Name>王武</Name> --<Sex>男</Sex> --</People> --<People> --<Name>趙柳</Name> --<Sex>女</Sex> --</People> --<People> --<Name>武士刀</Name> --<Sex>男</Sex> --</People> --</Peoples> --</Data>--調用webService----------------declare @ServiceUrl as varchar(1000) DECLARE @UrlAddress varchar(500)--WebService地址:以http開頭,結尾帶斜杠,例如'https://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx/' set @UrlAddress = 'http://localhost:11687/home/webxml'SET @ServiceUrl=@UrlAddress--如果有參數可以在此處拼入--訪問地址獲取結果Declare @Object as IntDeclare @ResponseText as Varchar(8000) --必須8000Declare @Data as XML EXEC sp_OACreate 'MSXML2.XMLHTTP', @Object OUT; --創建OLE組件對象Exec sp_OAMethod @Object, 'open', NULL, 'POST',@ServiceUrl,'false' --打開鏈接,注意是get還是postExec sp_OAMethod @Object, 'send'EXEC sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT --輸出參數Select @ResponseText --輸出結果SET @Data = CAST(@ResponseText AS XML)select t.c.value('(Name/text())[1]','VARCHAR(20)') as Name,t.c.value('(Sex/text())[1]','VARCHAR(20)') as Sexfrom @Data.nodes('/*/*/*') as t(c)Exec sp_OADestroy @ObjectGO----開啟 Ole Automation Procedures --sp_configure 'show advanced options', 1; --GO --RECONFIGURE; --GO --sp_configure 'Ole Automation Procedures', 1; --GO --RECONFIGURE; --GO --EXEC sp_configure 'Ole Automation Procedures'; --GO----關閉 Ole Automation Procedures --sp_configure 'show advanced options', 0; --GO --RECONFIGURE; --GO --sp_configure 'Ole Automation Procedures', 0; --GO --RECONFIGURE; --GO --EXEC sp_configure 'Ole Automation Procedures'; --GO
----開啟Ad Hoc Distributed Queries組件,在sql查詢編輯器中執行如下語句: --exec sp_configure 'show advanced options',1 --reconfigure --exec sp_configure 'Ad Hoc Distributed Queries',1 --reconfigure ----關閉Ad Hoc Distributed Queries組件,在sql查詢編輯器中執行如下語句: --exec sp_configure 'Ad Hoc Distributed Queries',0 --reconfigure --exec sp_configure 'show advanced options',0 --reconfigure

?

?

?

轉載于:https://www.cnblogs.com/GoCircle/p/9401188.html

總結

以上是生活随笔為你收集整理的使用SQL Server连接xml接口,读取并解析数据的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。