Xml Parsing Issue in sql job
<p>I am getting an error while executing the query in a SQL Server job. But if I execute it directly, it works fine.</p>

<p>Executed as user: NT AUTHORITY\SYSTEM. </p>

<blockquote>
  <p>XML parsing: line 10, character 33<br>
  Unexpected end of input [SQLSTATE 42000] (Error 9400). The step failed.<br>
  SQL Severity 16, SQL Message ID 9400</p>
</blockquote>

<p>Code:</p>

<pre><code>    declare  @URL VARCHAR(max) 

    set @url = 'http://www.spa.gov.sa/english/rss.xml'

    declare  @xmlT TABLE (yourXML XML)
    DECLARE @Response nvarchar(max)
    DECLARE @XML xml
    DECLARE @Obj int 
    DECLARE @Result int 
    DECLARE @HTTPStatus int 
    DECLARE @ErrorMsg nvarchar(MAX)

    EXEC @Result = sp_OACreate 'MSXML2.XMLHttp', @Obj OUT 

    EXEC @Result = sp_OAMethod @Obj, 'open', NULL, 'GET', @URL, false
    EXEC @Result = sp_OAMethod @Obj, 'setRequestHeader', NULL, 'Content-Type', 'application/x-www-form-urlencoded'
    EXEC @Result = sp_OAMethod @Obj, send, NULL, ''
    EXEC @Result = sp_OAGetProperty @Obj, 'status', @HTTPStatus OUT 

    INSERT @xmlT ( yourXML )
    EXEC @Result = sp_OAGetProperty @Obj, 'responseXML.xml'--, @Response OUT 


    INSERT into Tlb(discp, tit, datee, linkk)
</code></pre>

<p><strong>--below statement creates problem when i remove this statement it works fine everywhere</strong></p>

<pre><code>        SELECT   
            N.C.value('description[1]', 'nvarchar(max)') discp,   
            N.C.value('title[1]', 'varchar(999)') tit,
            N.C.value('pubDate[1]', 'varchar(99)') datee,
            N.C.value('link[1]', 'varchar(999)') linkk
        FROM
            @xmlT 
        CROSS APPLY 
            yourXML.nodes('//channel/item') N(C)
</code></pre>