The XML parse error 0xc00ce508 occurred


XML throws error while parsing because of improper encoding.

XML parsing error : The XML parse error 0xc00ce508 occurred on line number 31, near the XML text

Error : This errors occurs when trying to parse xml string by using sp_xml_preparedocument procedure.

cause : 1. XML is using UTF-8 encoding but some of the characters in xml string are UTF-16.
2. xml predefines five entity references for special character. if xml string contains following chars.
&,>,<,",'
solution :
1. Change XML datatype to nvarchar and remove xml encoding.
2. Change xml datatype to nvarchar and change encoding to UTF-16
3. Remove predefined five entity references.


& - &
< - <
> - >
" - "
' - '

How to change xml encoding

DECLARE @XML nVARCHAR(MAX)
SET @XML = N'< ?xml version="1.0" encoding="UTF-16"? >< Deals >
< Deal DealID="44" >
< DealHeader DealID="44" DealHeaderID="1001" >
< Detail CustomerID="1" CustomerAddress="AT" >
< Product Name="A" />
< /Detail >
< Detail CustomerID="2" CustomerAddress="B" >
< Product Name="B" / >
< /Detail >

< /DealHeader >
< /Deal >

'


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: