Does anyone know why this XML text throws an invalid character name error in SQL Server 2008?
'<cs><ca="2" b="CITY & STATE TX" c="CITY & STATE TX"/></cs>'
Exception message
Msg 9421, Level 16, State 1, Line 2 XML parsing: line 1, character 23, illegal name character
The following is the query used to parse this XML
DECLARE @CaptionsDescriptions XML = '<cs><ca="2" b="CITY & STATE TX" c="CITY & STATE TX"/></cs>' DECLARE @DocHandle int DECLARE @CaptionsDescriptionsTable TABLE ( ID INT IDENTITY(1,1), languageID INT, Caption VARCHAR(50), Description VARCHAR(2000) ) EXEC sp_xml_preparedocument @DocHandle OUTPUT,@CaptionsDescriptions INSERT INTO @CaptionsDescriptionsTable SELECT a,b,c FROM OPENXML(@DocHandle,'cs/c') WITH ( a int,
source share