当xml包含特定值时,将其替换为所有节点值 [英] Replace xml all node values when it contains certain value
问题描述
我有xml数据,我需要查询xml 并替换节点值 特别是字符串 如果它包含该字符串。
"<?xml version ="" ; 1.0"" encoding ="" utf-8""?>
< root>
< data name ="" Name1"" xml:space =""保留"">
&NBSP; < value>节点{0}包含{1}属性。文件{2}的处理已终止。< / value>
< / data>
< data name ="" Name2"" xml:space =""保留"">
&NBSP; < value>属性"{0}"来自节点"{1}"的测试数据。< / value>
< / data>
< data name ="" Name3"" xml:space =""保留"">
&NBSP; < value>属性"{0}"来自节点"{1}"的测试数据。< / value>
< / data>
< / root>
< / xml>"
$ b上面的xml中的$ b
我需要替换字符串"Test Data"。使用"样本数据"在什么节点的xml数据
< hr>
- David
检查出来
https://docs.microsoft.com/en-us/sql/t-sql/xml/replace-value-of-xml-dml?view=sql- server-2017
------------------------ -------------------------------------------
如果有帮助,请记得将回复标记为答案
Hi,
i'm having xml data, in which i need to query the xml and replace the node value particular string alone if it contains that string.
"<?xml version=""1.0"" encoding=""utf-8""?>
<root>
<data name=""Name1"" xml:space=""preserve"">
<value>Node {0} contain {1} attribute. Processing of file {2} terminated.</value>
</data>
<data name=""Name2"" xml:space=""preserve"">
<value>Attribute '{0}' Test Data from node '{1}'.</value>
</data>
<data name=""Name3"" xml:space=""preserve"">
<value>Attribute '{0}' Test Data from node '{1}'.</value>
</data>
</root>
</xml>"
in the above xml i need to replace the string "Test Data" with "Sample Data" in what ever nodes of the xml data
- David
Check this out
https://docs.microsoft.com/en-us/sql/t-sql/xml/replace-value-of-xml-dml?view=sql-server-2017
------------------------------------------------------------------
Please remember to mark the replies as answers if they help
这篇关于当xml包含特定值时,将其替换为所有节点值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!