使用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

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/249832.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/249832.shtml
英文地址,請注明出處:http://en.pswp.cn/news/249832.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

mac 卸載編輯器卸不干凈

Configuration~/Library/Preferences/Caches~/Library/Caches/Plugins~/Library/Application Support/Logs~/Library/Logs/轉載于:https://www.cnblogs.com/smzd/p/10114540.html

vue中使用axios最詳細教程

前提條件&#xff1a;vue-cli 項目 安裝&#xff1a; npm npm 在main.js導入&#xff1a; // 引入axios&#xff0c;并加到原型鏈中 import axios from axios; Vue.prototype.$axios axios; import QS from qs Vue.prototype.qs QS;封裝好的axios,拿走不送&#xff1a;&am…

Java 類型轉換String,List,Map,Array

1. JsonString轉為Map String jsoNStr "{\n" "\t\"TestArray\": [\"1\", \"2\", \"3\"]\n" "}";Map map JSON.parseObject(jsoNStr,Map.class);2.Object轉為JsonArray(得保證obj是個Array數組&#x…

關于固件

固件(Firmware)就是寫入EROM或EPROM(可編程只讀存儲器)中的程序&#xff0c;通俗的理解就是“固化的軟件”&#xff0c;臺港澳稱為“韌體”。更簡單的說&#xff0c;固件就是BIOS的軟件&#xff0c;但又與普通軟件完全不同&#xff0c;它是固化在集成電路內部的程序代碼&#x…

React-Native 指定模擬器RUN-IOS

react-native run-ios --simulator "iPhone 7” 轉載于:https://www.cnblogs.com/smzd/p/10185263.html

vue和element-ui使用

上一篇已經創建好一個vue項目。https://mp.csdn.net/postedit/80926242 這一篇主要是創建一個vue項目并結合餓了么框架element-ui。 1.先創建vue項目&#xff0c;我準備把項目放在e盤下&#xff1a;E:\Work\RegisterProject&#xff1b; 命令行進入這個目錄&#xff1a; 創…

javaweb學習6——自定義標簽

聲明&#xff1a;本文只是自學過程中&#xff0c;記錄自己不會的知識點的摘要&#xff0c;如果想詳細學習JavaWeb&#xff0c;請到孤傲蒼狼博客學習&#xff0c;JavaWeb學習點此跳轉 本文鏈接&#xff1a;https://www.cnblogs.com/xdp-gacl/p/3916946.html https://www.cnblogs…

goland 實用鍵

代碼補全 option command v轉載于:https://www.cnblogs.com/smzd/p/10313417.html

關于Mysql java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)的問題...

問題所在&#xff1a; 1.連接數據庫一個是密碼是否正確&#xff0c; 2.driver是否對&#xff0c; 3.有么有jar包沖突&#xff0c;轉載于:https://www.cnblogs.com/java-123/p/9403412.html

vscode配置vue環境

一、安裝VSCode、NodeJS VSCode&#xff1a;https://code.visualstudio.com/ NodeJS&#xff1a;https://nodejs.org/en/ 二、打開VSCode&#xff0c;安裝常用插件 如圖所示&#xff08;安裝后重新加載即可&#xff09;: 三、項目中添加.vscode文件夾&#xff0c;文件夾中添…

秒殺核心設計(減庫存部分)-防超賣與高并發

商品詳情頁面的靜態化&#xff0c;varnish加速&#xff0c;秒殺商品庫獨立部署服務器這種就略過不講了。只討論庫存部分的優化 mysql配置層面的優化可以參考我的這篇文章 《關于mysql innodb引擎性能優化的一點心得》 重點設計在數據庫層面。 2張表&#xff1a; 第一張&#xf…

go strconv

strconv是golang用來做數據類型轉換的一個庫。 介紹下strconv最常用的兩個方法, 沒有解釋語言那么自在可以str(int),int(string), 那還算簡練。 num, err : strconv.Atoi("-42") str : strconv.Itoa(-42)轉換換成bool類型. b, err : strconv.ParseBool("true&qu…

django配置templates、static、media和連接mysql數據庫

1.模板文件 # templates配置 if os.path.exists(os.path.join(BASE_DIR, templates)) is False:os.mkdir(os.path.join(BASE_DIR, templates)) TEMPLATES [{# 模板引擎&#xff0c;內置的模板引擎有&#xff1a;# 1. django.template.backends.django.DjangoTemplates# 2. dj…

vue調用順序(初學版) index.html → main.js → app.vue → index.js → components/組件 測試

關于它是怎么調用運作的&#xff1a;https://mp.csdn.net/postedit/86134414 一. 準備工作&#xff1a; 1.下載webstorm&#xff0c;安裝vue。 2.創建項目&#xff0c;cd到要放項目的文件夾下 vue init webpack vue_test 3.安裝各種包 npm install 4.運行 cd vue_test …

web開發:jquery之DOM

一、文檔結構 二、文檔操作 三、文檔操作案例 四、form表單 五、正則 六、form案例 一、文檔結構 jsvar $sup $(.sup);console.log($sup.children()); // 子們console.log($sup.parent()); // 父console.log($sup.prev()); // 上兄弟console.log($sup.next()); // 下兄弟c…

NO.8:自學python之路------并行socket網絡編程

摘要 一到放假就雜事很多&#xff0c;這次的作業比較復雜&#xff0c;做了一個周&#xff0c;進度又拖了。不過結果還不錯。 正文 粘包 在上一節中&#xff0c;如果連續發送過多數據&#xff0c;就可能發生粘包。粘包就是兩次發送的數據粘在一起被接收&#xff0c;損壞了數據的…

vue項目中主要文件的加載順序(index.html、App.vue、main.js)

先后順序&#xff1a; index.html > App.vue的export外的js代碼 > main.js > App.vue的export里面的js代碼 > Index.vue的export外的js代碼 測試的頁面代碼塊&#xff1a; 文件的加載先后順序&#xff1a; Index.vue的mounted()中的輸出沒有執行。why&#…

Http請求報頭設置(C#)

1、添加一個SetHeaderValue方法&#xff1a; public static void SetHeaderValue(WebHeaderCollection header, string name, string value) { var property typeof(WebHeaderCollection).GetProperty("InnerCollection",BindingFlags.Instance | BindingFlags.NonP…

vue-cli3使用cdn引入

1. index.html引入&#xff1a; <script src"https://cdn.bootcss.com/moment.js/2.20.1/moment.min.js"></script> <script src"https://cdn.bootcss.com/moment.js/2.20.1/locale/zh-cn.js"></script>2. vue.config.js配置&…

vue常用屬性

Vue實例常用屬性 1.數據 data:Vue 實例的數據對象 components&#xff1a;Vue實例配置局部注冊組件 1.類方法 computed:計算屬性 watch&#xff1a;偵聽屬性 filters&#xff1a;過濾器 methods:Vue實例方法 render&#xff1a;渲染函數&#xff0c;創建虛擬DOM 1.生命周期 c…