我正在解析一個xml文本,其中包含像'áéñ'這樣的字符。Sql 2008,無效字符解析xml,帶字符的波浪號
我收到'在文本內容中發現無效字符'。錯誤,這樣
declare @Xml varchar(100)
set @Xml =
'
<?xml version="1.0" encoding="UTF-8"?>
<Root>á</Root>
'
declare @XmlId integer
execute dbo.sp_xml_preparedocument @XmlId output, @Xml
select * from openXml(@XmlId, '/', 2) with (
Root varchar(10)
)
execute dbo.sp_xml_removedocument @XmlId
而且我發現了以下錯誤:
The XML parse error 0xc00ce508 occurred on line number 3, near the XML text "<Root>".
Msg 6602, Level 16, State 2, Procedure sp_xml_preparedocument, Line 1
The error description is 'An invalid character was found in text content.'.
Msg 8179, Level 16, State 5, Line 13
Could not find prepared statement with handle 0.
Msg 6607, Level 16, State 3, Procedure sp_xml_removedocument, Line 1
sp_xml_removedocument: The value supplied for parameter number 1 is invalid.
是否有某種方式,SQL可以解析這個XML?或者問題是編碼?
是對這些字符進行編碼的唯一解決方案還是有更好的方法來解決它?
打印出你的@Xml,你應該看到這個 – Paparazzi