XML 控制字符解析错误:非法 xml 字符

XML parsing error for control character: illegal xml character

我正在处理 API 调用和检索 xml,如下所述。

<?xml version="1.0" encoding="utf-16"?>
<backlinks>
<asd><Click Here for &#x3; tips to help you get around></asd>
<sourcetitle>《新加坡》住宿@戴斯旅店 Days Hotel Singapore-歡遊世界</sourcetitle>
</backlinks>

我正在使用 SQL Server 2008,我的数据库 table 中有一个 xml 列,我想在其中存储该值。

我尝试使用 CDATA,它对 &#x3; 工作正常,如果我从 xml 字符串中删除整个提到的 xml 的编码,它也能正常工作。但是当我尝试检索 xml 时,它显示如下。

<backlinks>
<asd>Click Here for &amp;#x3; tips to help you get around</asd>
<sourcetitle>«???»??@???? Days Hotel Singapore-????</sourcetitle>
</backlinks>

我想要的正是我作为输入输入的输出。

提前谢谢大家。

确保将列或值转换为 nvarchar。 SELECT 没有 N:

SELECT 
'<?xml version="1.0" encoding="utf-16"?>
<backlinks>
<asd><Click Here for &#x3; tips to help you get around></asd>
<sourcetitle>《新加坡》住宿@戴斯旅店 Days Hotel Singapore-歡遊世界</sourcetitle>
</backlinks>'

Returns:

<?xml version="1.0" encoding="utf-16"?>  <backlinks>  <asd><Click Here for &#x3; tips to help you get around></asd>  <sourcetitle>**«???»??@????** Days Hotel Singapore-????</sourcetitle>  </backlinks>

SELECT 与 N:

SELECT 
N'<?xml version="1.0" encoding="utf-16"?>
<backlinks>
<asd><Click Here for &#x3; tips to help you get around></asd>
<sourcetitle>《新加坡》住宿@戴斯旅店 Days Hotel Singapore-歡遊世界</sourcetitle>
</backlinks>'

Returns:

<?xml version="1.0" encoding="utf-16"?>  <backlinks>  <asd><Click Here for &#x3; tips to help you get around></asd>  <sourcetitle>《新加坡》住宿@戴斯旅店 Days Hotel Singapore-歡遊世界</sourcetitle>  </backlinks>