how to parse xml with special character in sql server

后端 未结 3 1249
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-20 01:07

I am getting following error when i add < in my xml,

Msg 9455, Level 16, State 1, Line 6 XML parsing: line 4, character 14, illegal qual

3条回答
  •  心在旅途
    2021-02-20 01:47

    You need to ensure the XML is valid, so you need to make sure any special characters are encoded.

    e.g.

    DECLARE @MyXML XML
    SET @MyXML = '
    
    W < hite
    Blue
    Black
    Green
    Red
    
    
    Apple
    Pineapple
    Grapes
    Melon
    
    '
    

提交回复
热议问题