使用sql验证xml [英] To validate xml using sql
本文介绍了使用sql验证xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我的表中有一列,其中包含xml标记,如下所示
Hi
I have a column in my table which contains xml tags as follows
<customerdetail>
<customer>Test</customer>
<detail>Test Detail</detai>
<Price />
</customerdetail>
如何使用sql验证标签
how to validate the tags using sql
推荐答案
试试这个
declare @xmlString VARCHAR(MAX) =' <customerdetail>
<customer>Test</customer>
<detail>Test Detail
<price />
</detail></customerdetail>'
SELECT CAST(@xmlString AS XML)
如果以上代码返回任何错误,则可以确认XML无效.如果不是,则无效.
谢谢
If above code returns any error then you can confirm the XML is invalid. If not it is valid.
Thank you
这篇关于使用sql验证xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文