pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <bdo id='fFXuv'></bdo><ul id='fFXuv'></ul>

  1. <tfoot id='fFXuv'></tfoot>
  2. <i id='fFXuv'><tr id='fFXuv'><dt id='fFXuv'><q id='fFXuv'><span id='fFXuv'><b id='fFXuv'><form id='fFXuv'><ins id='fFXuv'></ins><ul id='fFXuv'></ul><sub id='fFXuv'></sub></form><legend id='fFXuv'></legend><bdo id='fFXuv'><pre id='fFXuv'><center id='fFXuv'></center></pre></bdo></b><th id='fFXuv'></th></span></q></dt></tr></i><div class="jzdt5bn" id='fFXuv'><tfoot id='fFXuv'></tfoot><dl id='fFXuv'><fieldset id='fFXuv'></fieldset></dl></div>

    <small id='fFXuv'></small><noframes id='fFXuv'>

      <legend id='fFXuv'><style id='fFXuv'><dir id='fFXuv'><q id='fFXuv'></q></dir></style></legend>

      帶有 CDATA 塊的 SQL Server XML 數(shù)據(jù)

      SQL Server XML Data with CDATA Block(帶有 CDATA 塊的 SQL Server XML 數(shù)據(jù))

        <tbody id='srzYT'></tbody>

        <small id='srzYT'></small><noframes id='srzYT'>

          <tfoot id='srzYT'></tfoot>

          • <bdo id='srzYT'></bdo><ul id='srzYT'></ul>
            <i id='srzYT'><tr id='srzYT'><dt id='srzYT'><q id='srzYT'><span id='srzYT'><b id='srzYT'><form id='srzYT'><ins id='srzYT'></ins><ul id='srzYT'></ul><sub id='srzYT'></sub></form><legend id='srzYT'></legend><bdo id='srzYT'><pre id='srzYT'><center id='srzYT'></center></pre></bdo></b><th id='srzYT'></th></span></q></dt></tr></i><div class="fpvntnp" id='srzYT'><tfoot id='srzYT'></tfoot><dl id='srzYT'><fieldset id='srzYT'></fieldset></dl></div>

              <legend id='srzYT'><style id='srzYT'><dir id='srzYT'><q id='srzYT'></q></dir></style></legend>
                本文介紹了帶有 CDATA 塊的 SQL Server XML 數(shù)據(jù)的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                問(wèn)題描述

                限時(shí)送ChatGPT賬號(hào)..

                我將 XML 負(fù)載存儲(chǔ)在數(shù)據(jù)類(lèi)型為XML"的 SQL Server 表中.我收到的數(shù)據(jù)有一個(gè)包含在 CDATA 塊中的部分.下面是一個(gè)例子:

                I am storing an XML payload in a SQL Server table that has a datatype of 'XML'. The data I am receiving has a section that is enclosed in a CDATA block. Here is an example:

                <event>
                  <projectId>123456</projectId>
                  <eventTs>2018-01-04T13:07:23</eventTs>
                  <eventData>
                    <![CDATA[
                    <company>
                      <companyId>849</companyId>
                      <companyName>My Company Name</companyName>
                      <activeFlag>Y</activeFlag>
                      <timestamp>27-JUL-17</timestamp>
                    </company>
                    ]]>
                  </eventData>
                </event>
                

                當(dāng)這些數(shù)據(jù)出現(xiàn)在我的表中具有XML"數(shù)據(jù)類(lèi)型的字段中時(shí),CDATA"塊被剝離,但隨后所有的<"和 ">" 字符被轉(zhuǎn)義.由于這些字符已被轉(zhuǎn)義,因此對(duì)該數(shù)據(jù)字段的 XPATH 查詢(xún)不再有效.除了必須在插入/轉(zhuǎn)換為 XML 數(shù)據(jù)類(lèi)型之前去掉 CDATA 塊之外,還有什么辦法可以解決這種行為?

                when this data lands in my table in the field that has a data type of 'XML' the 'CDATA' block is stripped out but then all of the "<" and ">" characters are escaped. Since those characters are escaped, XPATH queries on that data field no longer work. Is there any way around this behavior short of having to strip out the CDATA block before it is inserted/converted to an XML data type?

                這是插入到 XML 數(shù)據(jù)類(lèi)型字段后的數(shù)據(jù):

                This is what the data looks like after being inserted into the XML datatype field:

                <event>
                    <projectId>123456</projectId>
                    <eventTs>2018-01-04T13:07:23</eventTs>
                    <eventData>
                &lt;company&gt;
                          &lt;companyId&gt;849&lt;/companyId&gt;
                &lt;companyName&gt;My Company Name&lt;/companyName&gt;
                &lt;activeFlag&gt;Y&lt;/activeFlag&gt;
                &lt;timestamp&gt;27-JUL-17&lt;/timestamp&gt;
                &lt;/company&gt;
                </eventData>
                </event>
                

                推薦答案

                CDATA 部分中存儲(chǔ) XML 是一種非常糟糕的方法.此塊中的所有內(nèi)容都只是文本.此特殊文本看起來(lái)像一個(gè) XML,但您無(wú)法查詢(xún)此 XML 以返回 .

                It is a very bad approach to store XML within a CDATA section. Everything within this block is just text. This special text looks like an XML, but you cannot query this XML to return the <companyName>.

                試試這個(gè):

                DECLARE @xml XML=
                N'<event>
                  <projectId>123456</projectId>
                  <eventTs>2018-01-04T13:07:23</eventTs>
                  <eventData>
                    <![CDATA[
                    <company>
                      <companyId>849</companyId>
                      <companyName>My Company Name</companyName>
                      <activeFlag>Y</activeFlag>
                      <timestamp>27-JUL-17</timestamp>
                    </company>
                    ]]>
                  </eventData>
                </event>';
                

                SQL Server 的開(kāi)發(fā)人員甚至決定不再支持 CDATA.它會(huì)被隱含地帶走,而它的內(nèi)容仍然被正確地轉(zhuǎn)義.但是你可以毫無(wú)問(wèn)題地閱讀內(nèi)容:

                SQL Server's developer decided not even to support CDATA anymore. It will implicitly be taken away, while its content remains properly escaped. But you can read the content without problems:

                SELECT @xml.value('(/event/eventData)[1]','nvarchar(max)');  
                

                重點(diǎn)是:這個(gè)結(jié)果看起來(lái)像一個(gè) XML,但是 - 為了使用它像一個(gè) XML - 它必須被強(qiáng)制轉(zhuǎn)換.

                The point is: This result looks like an XML, but - in order to use it like an XML - it must be casted.

                你可以這樣做來(lái)解決這個(gè)問(wèn)題:

                This you could do to solve this:

                DECLARE @innerXML XML=(SELECT CAST('<eventData>' + @xml.value('(/event/eventData)[1]','nvarchar(max)') + '</eventData>' AS XML));
                SET @xml.modify('delete /event/eventData[1]');
                SET @xml.modify('insert sql:variable("@innerXML") as last into /event[1]');
                SELECT @xml;
                

                簡(jiǎn)單易行:

                只要傳入的 XML 是一個(gè)字符串(在您嘗試將其轉(zhuǎn)換為 XML 之前),您就可以丟棄 CDATA 標(biāo)記:

                DECLARE @xmlString NVARCHAR(MAX)=
                N'<event>
                  <projectId>123456</projectId>
                  <eventTs>2018-01-04T13:07:23</eventTs>
                  <eventData>
                    <![CDATA[
                    <company>
                      <companyId>849</companyId>
                      <companyName>My Company Name</companyName>
                      <activeFlag>Y</activeFlag>
                      <timestamp>27-JUL-17</timestamp>
                    </company>
                    ]]>
                  </eventData>
                </event>';
                
                SELECT CAST(REPLACE(REPLACE(@xmlString,' <![CDATA[',''),']]>','') AS XML)
                

                這篇關(guān)于帶有 CDATA 塊的 SQL Server XML 數(shù)據(jù)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?(我可以在不編寫(xiě) SQL 查詢(xún)的情況下找出數(shù)據(jù)庫(kù)列表和 SQL Server 實(shí)例使用的空間嗎?) - IT屋-程序員軟件開(kāi)發(fā)
                How to create a login to a SQL Server instance?(如何創(chuàng)建對(duì) SQL Server 實(shí)例的登錄?)
                How to know the version and edition of SQL Server through registry search(如何通過(guò)注冊(cè)表搜索知道SQL Server的版本和版本)
                Why do I get a quot;data type conversion errorquot; with ExecuteNonQuery()?(為什么會(huì)出現(xiàn)“數(shù)據(jù)類(lèi)型轉(zhuǎn)換錯(cuò)誤?使用 ExecuteNonQuery()?)
                How to show an image from a DataGridView to a PictureBox?(如何將 DataGridView 中的圖像顯示到 PictureBox?)
                WinForms application design - moving documents from SQL Server to file storage(WinForms 應(yīng)用程序設(shè)計(jì)——將文檔從 SQL Server 移動(dòng)到文件存儲(chǔ))
              • <legend id='xkg1x'><style id='xkg1x'><dir id='xkg1x'><q id='xkg1x'></q></dir></style></legend>
                  <tbody id='xkg1x'></tbody>
                <i id='xkg1x'><tr id='xkg1x'><dt id='xkg1x'><q id='xkg1x'><span id='xkg1x'><b id='xkg1x'><form id='xkg1x'><ins id='xkg1x'></ins><ul id='xkg1x'></ul><sub id='xkg1x'></sub></form><legend id='xkg1x'></legend><bdo id='xkg1x'><pre id='xkg1x'><center id='xkg1x'></center></pre></bdo></b><th id='xkg1x'></th></span></q></dt></tr></i><div class="okgqoae" id='xkg1x'><tfoot id='xkg1x'></tfoot><dl id='xkg1x'><fieldset id='xkg1x'></fieldset></dl></div>

                      • <small id='xkg1x'></small><noframes id='xkg1x'>

                        <tfoot id='xkg1x'></tfoot>
                        • <bdo id='xkg1x'></bdo><ul id='xkg1x'></ul>
                          主站蜘蛛池模板: 27PR跨境电商导航 | 专注外贸跨境电商 | 美缝剂_美缝剂厂家_美缝剂加盟-地老板高端瓷砖美缝剂 | 六自由度平台_六自由度运动平台_三自由度摇摆台—南京全控科技 | 节流截止放空阀-不锈钢阀门-气动|电动截止阀-鸿华阀门有限公司 | 铝板冲孔网,不锈钢冲孔网,圆孔冲孔网板,鳄鱼嘴-鱼眼防滑板,盾构走道板-江拓数控冲孔网厂-河北江拓丝网有限公司 | 创客匠人-让IP变现不走弯路| 一级建造师培训_一建培训机构_中建云筑建造师培训网校 | 河北码上网络科技|邯郸小程序开发|邯郸微信开发|邯郸网站建设 | 预制舱-电力集装箱预制舱-模块化预制舱生产厂家-腾达电器设备 | 珠海白蚁防治_珠海灭鼠_珠海杀虫灭鼠_珠海灭蟑螂_珠海酒店消杀_珠海工厂杀虫灭鼠_立净虫控防治服务有限公司 | MES系统-WMS系统-MES定制开发-制造执行MES解决方案-罗浮云计算 | 气动|电动调节阀|球阀|蝶阀-自力式调节阀-上海渠工阀门管道工程有限公司 | 杭州画室_十大画室_白墙画室_杭州美术培训_国美附中培训_附中考前培训_升学率高的画室_美术中考集训美术高考集训基地 | 烟台螺纹,烟台H型钢,烟台钢材,烟台角钢-烟台市正丰金属材料有限公司 | 烟气换热器_GGH烟气换热器_空气预热器_高温气气换热器-青岛康景辉 | 嘉兴恒升声级计-湖南衡仪声级计-杭州爱华多功能声级计-上海邦沃仪器设备有限公司 | 干式变压器厂_干式变压器厂家_scb11/scb13/scb10/scb14/scb18干式变压器生产厂家-山东科锐变压器有限公司 | 飞利浦LED体育场灯具-吸顶式油站灯-飞利浦LED罩棚灯-佛山嘉耀照明有限公司 | 根系分析仪,大米外观品质检测仪,考种仪,藻类鉴定计数仪,叶面积仪,菌落计数仪,抑菌圈测量仪,抗生素效价测定仪,植物表型仪,冠层分析仪-杭州万深检测仪器网 | 电磁流量计_智能防腐防爆管道式计量表-金湖凯铭仪表有限公司 | 水厂自动化|污水处理中控系统|水利信息化|智慧水务|智慧农业-山东德艾自动化科技有限公司 | 希望影视-高清影视vip热播电影电视剧免费在线抢先看 | 保镖公司-私人保镖-深圳保镖公司【环宇兄弟保镖】 | 烟台游艇培训,威海游艇培训-烟台市邮轮游艇行业协会 | 台湾阳明固态继电器-奥托尼克斯光电传感器-接近开关-温控器-光纤传感器-编码器一级代理商江苏用之宜电气 | 北京软件开发_软件开发公司_北京软件公司-北京宜天信达软件开发公司 | 山东led显示屏,山东led全彩显示屏,山东LED小间距屏,临沂全彩电子屏-山东亚泰视讯传媒有限公司 | RTO换向阀_VOC高温阀门_加热炉切断阀_双偏心软密封蝶阀_煤气蝶阀_提升阀-湖北霍科德阀门有限公司 | 中国玩具展_玩具展|幼教用品展|幼教展|幼教装备展 | 成都APP开发-成都App定制-成都app开发公司-【未来久】 | ?水马注水围挡_塑料注水围挡_防撞桶-常州瑞轩水马注水围挡有限公司 | 台湾HIWIN上银直线模组|导轨滑块|TBI滚珠丝杆丝杠-深圳汉工 | 耐酸碱泵-自吸耐酸碱泵型号「品牌厂家」立式耐酸碱泵价格-昆山国宝过滤机有限公司首页 | 龙门加工中心-数控龙门加工中心厂家价格-山东海特数控机床有限公司_龙门加工中心-数控龙门加工中心厂家价格-山东海特数控机床有限公司 | 防爆正压柜厂家_防爆配电箱_防爆控制箱_防爆空调_-盛通防爆 | 碳化硅,氮化硅,冰晶石,绢云母,氟化铝,白刚玉,棕刚玉,石墨,铝粉,铁粉,金属硅粉,金属铝粉,氧化铝粉,硅微粉,蓝晶石,红柱石,莫来石,粉煤灰,三聚磷酸钠,六偏磷酸钠,硫酸镁-皓泉新材料 | 特种阀门-调节阀门-高温熔盐阀-镍合金截止阀-钛阀门-高温阀门-高性能蝶阀-蒙乃尔合金阀门-福建捷斯特阀门制造有限公司 | 安平县鑫川金属丝网制品有限公司,防风抑尘网,单峰防风抑尘,不锈钢防风抑尘网,铝板防风抑尘网,镀铝锌防风抑尘网 | 安徽泰科检测科技有限公司【官方网站】 | 浙江建筑资质代办_二级房建_市政_电力_安许_劳务资质办理公司 | 打造全球沸石生态圈 - 国投盛世|