久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <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="qwawimqqmiuu" 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 數據

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

        <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="qwawimqqmiuu" 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 數據的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我將 XML 負載存儲在數據類型為XML"的 SQL Server 表中.我收到的數據有一個包含在 CDATA 塊中的部分.下面是一個例子:

                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>
                

                當這些數據出現在我的表中具有XML"數據類型的字段中時,CDATA"塊被剝離,但隨后所有的<"和 ">" 字符被轉義.由于這些字符已被轉義,因此對該數據字段的 XPATH 查詢不再有效.除了必須在插入/轉換為 XML 數據類型之前去掉 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 數據類型字段后的數據:

                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 部分中存儲 XML 是一種非常糟糕的方法.此塊中的所有內容都只是文本.此特殊文本看起來像一個 XML,但您無法查詢此 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>.

                試試這個:

                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 的開發人員甚至決定不再支持 CDATA.它會被隱含地帶走,而它的內容仍然被正確地轉義.但是你可以毫無問題地閱讀內容:

                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)');  
                

                重點是:這個結果看起來像一個 XML,但是 - 為了使用它像一個 XML - 它必須被強制轉換.

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

                你可以這樣做來解決這個問題:

                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;
                

                簡單易行:

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

                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)
                

                這篇關于帶有 CDATA 塊的 SQL Server XML 數據的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

                Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?(我可以在不編寫 SQL 查詢的情況下找出數據庫列表和 SQL Server 實例使用的空間嗎?) - IT屋-程序員軟件開發
                How to create a login to a SQL Server instance?(如何創建對 SQL Server 實例的登錄?)
                How to know the version and edition of SQL Server through registry search(如何通過注冊表搜索知道SQL Server的版本和版本)
                Why do I get a quot;data type conversion errorquot; with ExecuteNonQuery()?(為什么會出現“數據類型轉換錯誤?使用 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 應用程序設計——將文檔從 SQL Server 移動到文件存儲)
              • <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="qwawimqqmiuu" 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>
                          主站蜘蛛池模板: 午夜a v电影 | 午夜一区二区三区在线观看 | 国精品一区| 国产一级黄色网 | 久久一区精品 | 亚洲日本欧美日韩高观看 | 国产乱码精品1区2区3区 | 欧美综合久久 | 黄色片视频网站 | 日本三级全黄三级a | 北条麻妃一区二区三区在线视频 | 久久久爽爽爽美女图片 | 免费性视频 | 国产精品视频999 | 久久国产婷婷国产香蕉 | 日韩午夜精品 | 久久久成人动漫 | 亚洲综合视频 | 成人免费看黄网站在线观看 | 亚洲美女av网站 | 久久区二区 | www.亚洲成人网 | 99精品一区二区 | 中文天堂在线观看 | 免费观看的黄色网址 | 黄色在线免费观看 | 国产精品视频在线观看 | 成人一区二区在线 | 欧美一级免费 | 久久精品网 | 欧美一级黑人aaaaaaa做受 | 中文字幕日韩欧美一区二区三区 | 黄色一级大片视频 | 日韩在线一区二区三区 | 久久香蕉精品视频 | 亚洲精品91 | www.操.com | 久久久爽爽爽美女图片 | 亚洲精品一区av在线播放 | 成人免费视频网站在线观看 | 亚洲一区久久久 |