How to get the xml-safe version of an sql server XML Column -
Is there any way to get XML-secured version of XML-Sacred version in SQL Server?
Secure from XML I mean that & lt;, & gt; & # 39; & # 39; & # 39; Etc. to avoid special characters like
I want to avoid replacing myself. There is a build in the function in SQL Server.
What I want to achieve is to store XML content in another XML attribute.
I think xml-safe means you mean to avoid XML special tags. If you have an XML column that you want to include in another XML document, then you have two options:
- Column to
[*]
:Select project as .., for the XML column [*], ... from ... to xml path ...
For example, this result will embed the XML content of columns in XML. If the value in the column isand element & gt; Value & lt; / Element & gt;
then the result is& lt; Root & gt; & Lt; Line & gt; & Lt; Element & gt; Price & lt; / Element & gt; & Lt; / Row & gt; & Lt; / Root & gt;
. - Project column as column name: Select
..., XML column, ... to ... xml path ... ...
the content of this column Will be included as a value (ie it will be saved). for example. The same value as mentioned above& lt; Root & gt; & Lt; Line & gt; & Lt; Xmlcolumn & gt; Element & amp; Gt; & Amp; Lt; Value & amp; the lift; / Elements & amp; Gt;
.
If your question is about something else, then you have to properly start it again and use the terms correctly.
Update :
If you are going to insert XML value in the column, then you do not invent new rules, do not do anything, libraries know the customer That is how to handle the proper avoidance. Remeber, XML No is a string and you should never be considered as one if you write your code correctly If you write XML, then use a suitable XML library (, etc.). When the SQL Server passes in XML, use the Approval Type:. The stored processes should use apopoite parameter type:. When you read it, use the appropriate method to read XML: It is also possible to declare a type of type from a miriad designer (LINQ to SQL, EF etc.). Finally, never do not need to manually avoid any XML characters. If you do this, then you are using the wrong API and you have to go back to the drawing board.
It's a good start to read.
And finally, to manipulate XML as you describe (table XML's XML column with table B), you use specially, and you use tables By binding the B column inside XQuery:
update one set somecolumn .modify ('Insert {sql: column ("Bidar column")} before the Somnode') But on BB ...;
You comment as a threat XML string and, as I said earlier, you should never do this: strings and XML are in the form of water and oil.
Comments
Post a Comment