title: SQL XML Parser Error: illegal name character
body: <p>I am trying to execute the following query:</p>
  
  <pre><code>SELECT CASE CAST(a.AnswerText as XML).value('(/AnswerData/Input[@Name = "AnswerData0"]/Value)[1]', 'varchar(100)')
  WHEN 'Other' THEN 'Self'
  WHEN 'man' THEN 'Manager'
  WHEN 'sub' THEN 'Suborbinate'
  WHEN 'Colleague' THEN 'Colleague'
  ELSE (CAST(a.AnswerText as XML).value('(/AnswerData/Input[@Name = "AnswerData0"]/Value)[1]', 'nvarchar(100)'))
  END as RelationShip, ta.TestAssignmentId
  </code></pre>
  
  <p>This is just a snippet of a much larger query, but this is where the error is being caused.
  The error being outputted is:</p>
  
  <pre><code>XML parsing: line 1, character 67, illegal name character
  </code></pre>
  
  <p>I realised this was a problem with the XML, so I checked the XML and it seems ok to me:</p>
  
  <pre><code>&lt;AnswerData&gt;&lt;Input Name="AnswerData0" Correct="false"&gt;&lt;Value&gt;Other&lt;/Value&gt;&lt;/Input&gt;&lt;/AnswerData&gt;
  &lt;AnswerData&gt;&lt;Input Name="AnswerData0" Correct="true"&gt;&lt;Value&gt;sub&lt;/Value&gt;&lt;/Input&gt;&lt;/AnswerData&gt;
  &lt;AnswerData&gt;&lt;Input Name="AnswerData0" Correct="false"&gt;&lt;Value&gt;Colleague&lt;/Value&gt;&lt;/Input&gt;&lt;/AnswerData&gt;
  &lt;AnswerData&gt;&lt;Input Name="AnswerData0" Correct="true"&gt;&lt;Value&gt;sub&lt;/Value&gt;&lt;/Input&gt;&lt;/AnswerData&gt;
  &lt;AnswerData&gt;&lt;Input Name="AnswerData0" Correct="false"&gt;&lt;Value&gt;Colleague&lt;/Value&gt;&lt;/Input&gt;&lt;/AnswerData&gt;
  &lt;AnswerData&gt;&lt;Input Name="AnswerData0" Correct="false"&gt;&lt;Value&gt;man&lt;/Value&gt;&lt;/Input&gt;&lt;/AnswerData&gt;
  &lt;AnswerData&gt;&lt;Input Name="AnswerData0" Correct="false"&gt;&lt;Value&gt;Colleague&lt;/Value&gt;&lt;/Input&gt;&lt;/AnswerData&gt;
  </code></pre>
  
  <p>Can anyone provide an insight or notice something in the XML which I have missed.</p>