title: XML parsing: line 1, character 23, illegal name character
body: <p>Does anybody know why this XML text throws illegal name character error in SQL Server 2008?</p>
  
  <pre><code>'&lt;cs&gt;&lt;c a="2" b="CITY &amp; STATE TX" c="CITY &amp; STATE TX"/&gt;&lt;/cs&gt;'
  </code></pre>
  
  <p>Exception message is </p>
  
  <pre><code>Msg 9421, Level 16, State 1, Line 2
  XML parsing: line 1, character 23, illegal name character
  </code></pre>
  
  <p>Following is the query used for parse this xml</p>
  
  <pre><code>DECLARE @CaptionsDescriptions XML = '&lt;cs&gt;&lt;c a="2" b="CITY &amp; STATE TX" c="CITY &amp; STATE TX"/&gt;&lt;/cs&gt;'
  
  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, -- language id  
      b varchar(50), -- caption  
      c varchar(2000) -- description  
     )  
  
  -- remove document handler  
  EXEC sp_xml_removedocument @DocHandle  
  </code></pre>