none
Error:"XML parsing: line 2, character 15, A string literal was expected"

    Question

  • Hi,

    I have created an xml like this. dynamically ,but when i run this i am getting the error:

    "XML parsing: line 2, character 15, A string literal was expected"

    

    following is the script:

    

    declare

    @p33 xml,@item NVARCHAR(MAX)

     

    declare @p37 nvarchar(5

    )

     

    declare @p38 bigint,@GUID VARCHAR(MAX

    )

     

    SET @GUID=NEWID() SET @GUID='AMS_'+

    @GUID

     

    select

    @GUID

     

    set @item=

    N'<questestinterop><qticomment>This is a multiple-choice static question</qticomment>

    <item ident='

     

    +@GUID+' '+

    'label="Com1" title="Multiple Choice Static" CIID="1096"><qticomment>

    <![CDATA[]]></qticomment><duration>P0Y0M0DT0H0M0S</duration><itemmetadata><qtimetadata>

    <qtimetadatafield><fieldlabel>qmd_weighting</fieldlabel><fieldentry>2.0</fieldentry></qtimetadatafield>

    </qtimetadata><qtimetadata><qtimetadatafield><fieldlabel>qmd_penaltyvalue</fieldlabel><fieldentry>0.0</fieldentry>

    </qtimetadatafield></qtimetadata><qmd_itemtype>Multiple Choice Static</qmd_itemtype>

    <qmd_levelofdifficulty>Easy</qmd_levelofdifficulty><qmd_maximumscore>1</qmd_maximumscore>

    <qmd_minimumscore>0</qmd_minimumscore><qmd_status>Normal</qmd_status><qmd_experiencelevel>None</qmd_experiencelevel>

    <qmd_classification></qmd_classification><qmd_toolvendor>Excelsoft</qmd_toolvendor><qmd_topic></qmd_topic>

    <qmd_weighting>2.00</qmd_weighting><qmd_page></qmd_page><qmd_type></qmd_type></itemmetadata>

    <presentation label="MultipleChoice"><material><mattext texttype="text/html">

    <![CDATA[<span style="font-family: Times New Roman; font-size: 12.5pt;">Following sentence contains certain words underlined, which may or may not be incorrect. Identify the option that contains the error and the correction suggested. <br />

    <br />His preference for green tea <u>to</u> coffee and such exotic items as parmesan cheese and pretzels <u>was</u> known to those close to him.</span>]]></mattext></material><response_lid ident="304449a8-aa4d-4054-8df8-9dfae1d4ac0f" rcardinality="Single" rtiming="No"><render_choice shuffle="No"><response_label ident="1"><flow_mat class="List"><material><mattext texttype="text/html"><![CDATA[<span style="font-family: Times New Roman; font-size: 12.5pt;"><u>to</u> to be replaced by <u>over</u></span>]]></mattext></material></flow_mat></response_label><response_label ident="2"><flow_mat class="List"><material><mattext texttype="text/html"><![CDATA[<span style="font-family: Times New Roman; font-size: 12.5pt;"><u>was</u> to be replaced by <u>were</u></span>]]></mattext></material></flow_mat></response_label><response_label ident="3"><flow_mat class="List"><material><mattext texttype="text/html"><![CDATA[<span style="font-family: Times New Roman; font-size: 12.5pt;"><u>to</u> to be replaced by <u>over</u> and <u>was</u> to be replaced by <u>were</u></span>]]></mattext></material></flow_mat></response_label><response_label ident="4"><flow_mat class="List"><material><mattext texttype="text/html"><![CDATA[<span style="font-family: Times New Roman; font-size: 12.5pt;">No error; No correction required</span>]]></mattext></material></flow_mat></response_label></render_choice></response_lid></presentation><resprocessing><outcomes><decvar varname="SCORE" vartype="Decimal" defaultval="0" /></outcomes><respcondition title="1" continue="No"><conditionvar><varequal respident="304449a8-aa4d-4054-8df8-9dfae1d4ac0f">1</varequal></conditionvar><setvar action="Set" varname="SCORE">1</setvar><displayfeedback feedbacktype="Response" linkrefid="1" /></respcondition><respcondition title="2" continue="No"><conditionvar><varequal respident="304449a8-aa4d-4054-8df8-9dfae1d4ac0f">2</varequal></conditionvar><setvar action="Set" varname="SCORE">0</setvar><displayfeedback feedbacktype="Response" linkrefid="2" /></respcondition><respcondition title="3" continue="No"><conditionvar><varequal respident="304449a8-aa4d-4054-8df8-9dfae1d4ac0f">3</varequal></conditionvar><setvar action="Set" varname="SCORE">0</setvar><displayfeedback feedbacktype="Response" linkrefid="3" /></respcondition><respcondition title="4" continue="No"><conditionvar><varequal respident="304449a8-aa4d-4054-8df8-9dfae1d4ac0f">4</varequal></conditionvar><setvar action="Set" varname="SCORE">0</setvar><displayfeedback feedbacktype="Response" linkrefid="4" /></respcondition></resprocessing><itemfeedback ident="1" view="All"><flow_mat><material><mattext texttype="text/html"><![CDATA[]]></mattext></material></flow_mat></itemfeedback><itemfeedback ident="2" view="All"><flow_mat><material><mattext texttype="text/html"><![CDATA[]]></mattext></material></flow_mat></itemfeedback><itemfeedback ident="3" view="All"><flow_mat><material><mattext texttype="text/html"><![CDATA[]]></mattext></material></flow_mat></itemfeedback><itemfeedback ident="4" view="All"><flow_mat><material><mattext texttype="text/html"><![CDATA[]]></mattext></material></flow_mat></itemfeedback><itemfeedback ident="Hints" view="All"><hint feedbackstyle="Multilevel"><hintmaterial><flow_mat><material><mattext texttype="text/html"><![CDATA[]]></mattext></material></flow_mat></hintmaterial><hintmaterial><flow_mat><material><mattext texttype="text/html"><![CDATA[]]></mattext></material></flow_mat></hintmaterial><hintmaterial><flow_mat><material><mattext texttype="text/html"><![CDATA[]]></mattext></material></flow_mat></hintmaterial></hint></itemfeedback></item></questestinterop>'

    Please help me .

     

    Regards

    Chaithanya M

     

    Friday, July 08, 2011 6:01 AM

Answers

  • This should be obvious. Each attribute value must be enclosed by quotation marks. You forgot these when inserting your GUID. E.g.

    SET @item = N'
    <qticomment>This is a multiple-choice static question</qticomment>
    <item ident="' + @GUID + '" ' + 'label="Com1" title="Multiple Choice Static" CIID="1096"><qticomment>
    ';

    btw, you've got further errors in you XML text. So I guess you should inspect it with an XML editor.


    Microsoft MVP Office Access
    https://mvp.support.microsoft.com/profile/Stefan.Hoffmann
    • Marked as answer by KJian_ Friday, July 15, 2011 8:58 AM
    Friday, July 08, 2011 7:57 AM