need help parsing xml

  • Scenario 1 works just fine

    DECLARE @XMLT XML = '<Header>

    <ReportDate>10032017</ReportDate>

    <ReportTime>140607</ReportTime>

    <Preamble>TWA1</Preamble>

    <ARFVersion>07</ARFVersion>

    </Header>'

    SELECT @XMLT AS TheXML;

    select

    Header.DT.value('ReportDate[1]' ,'VARCHAR(10)') AS ReportDate

    ,Header.DT.value('ReportTime[1]' ,'VARCHAR(10)') AS ReportTime

    ,Header.DT.value('Preamble[1]' ,'VARCHAR(10)') AS Preamble

    ,Header.DT.value('ARFVersion[1]' ,'VARCHAR(10)') AS ARFVersion

    FROM @XMLT.nodes('Header') AS Header(DT);

     

    but i have xml that has data like (highlighted in bold) and i get xml parsing error

    (XML parsing: line 6, character 21, A string literal was expected)

     

    DECLARE @XMLT XML = '<Header>

    <ReportDate>10032017</ReportDate>

    <ReportTime>140607</ReportTime>

    <Preamble>TWA1</Preamble>

    <ARFVersion>07</ARFVersion>

    <Evaluation code=\"P\"/>

    </Header>'

     

  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

  • Please do not cross post.  Please respond on this thread https://www.sqlservercentral.com/forums/topic/need-help-parsing-xml-3#post-3727725

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply