title: XML parsing: line 21, character 67, illegal qualified name character casting error?
body: <p>I am using SQL Server 2014 and when I run below query I get this error message:</p>
  
  <blockquote>
    <p>XML parsing: line 21, character 67, illegal qualified name character </p>
  </blockquote>
  
  <p>could this a casting error? My issue is that I dont know where is the problem is, I have read few questions regarding the similar issue, but still confused as to why this is happening can anyone please help me understand the error message. </p>
  
  <p>Context: I have table called <code>tasks</code> that stores <code>p_num</code> (product number) and <code>descript</code> which stores notes of date and person updated the product order. I want to retrieve the date and person's name. However the issue is each p_num has multiple notes and all the notes are stored in single cell for each p_num and they are separated by space only. This approach seems to help me get my result, but I am getting this error message. </p>
  
  <pre><code>  Sample of text field(Descript):
     11/6/2018 2:04pm Standard pacific time - m.doe I need help with this issue &amp; I might need help with this stupid issue 11/5/2018 1:05pm standard pacific time - m.doe I looked at the issue and I found it difficult to understand 11/4/2018 8:00am standard pacific time - j.moe issue has been registered
     end of all the note.
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>P_num    Date        Name
  100      11/6/2018   m.doe
  100      11/5/2018   m.doe
  100      11/4/2018   j.moe
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code> DECLARE @tmp13 TABLE
                  (
                     [p_Num] INTEGER NOT NULL,
                     [DESCRIPT] NVARCHAR(MAX)
                     PRIMARY KEY([p_Num])
                  );
  
  DECLARE @tmp13Parse TABLE
                      (
                          [Id] INT,
                          [Position] BIGINT,
                          [Value] NVARCHAR(500)
                          unique clustered ([Id], [Position])
                      );
  
  
   --insert test data
   INSERT INTO @tmp13 
    SELECT p_NUM,DESCRIPT FROM TASKS WHERE p_NUM &gt;250000;
  
  
  
  INSERT INTO @tmp13Parse (
                          [Id]
                        , [Position]
                        , [Value]
                      )
          SELECT      [a].[p_Num]
                    , [ss].[Position]
                    , [ss].[Value]
          FROM        @tmp13 [a]
          CROSS APPLY (
                          SELECT      ROW_NUMBER() OVER ( ORDER BY (SELECT 1)) 
   AS [Position]
                                    , [y].[i].[value]('(./text())[1]', 'nvarchar(max)') AS [Value]
                          FROM        (
                                          SELECT [x] = CONVERT(XML, '&lt;i&gt;'+ REPLACE([a].[DESCRIPT], ' ', '&lt;/i&gt;&lt;i&gt;')+ '&lt;/i&gt;').[query]('.')
                                      ) AS [a]
                          CROSS APPLY [x].[nodes]('i') AS [y]([i])
                      ) AS [ss];
  
  
  
   SELECT      [a].[Id]
        , [a].[Value] AS [Date]
        , [ccc].[Value] AS [Name]
   FROM        @tmp13Parse [a]
  
   CROSS APPLY (
              SELECT MIN([aa].[Position]) + 1 AS [nameAnchorPosition]
              FROM   @tmp13Parse [aa]
              WHERE  [aa].[Id] = [a].[Id]
                     AND [aa].[Value] = '-'
                     AND [aa].[Position] &gt; [a].[Position]
          ) AS [bb]
  
    CROSS APPLY (
              SELECT [cc].[Value]
              FROM   @tmp13Parse [cc]
              WHERE  [cc].[Id] = [a].[Id]
                     AND [cc].[Position] = [bb].[nameAnchorPosition]
                   )  AS [ccc]
     WHERE       TRY_CONVERT(DATE, [a].[Value]) &gt; '1900-01-01'; 
  </code></pre>