Single Quote / & Not working With Sp_Xml_PrepareDocument (Urgent)

  • DECLARE @StrXml varchar(8000)

    SET @StrXml = <employee name='jon''s dicosta & Co' />

    DECLARe @Idoc int

    EXEC Sp_Xml_PrepareDocument @idoc OUTPUT, @StrXml

    Gives error as

    XML Parsing Error

    If i Remove Single quote / &  then this error is not coming

    Sql Server 2000

    Product Version - 8.00.760 (Sp3)

    Waiting for your reply

    Thanks in advance

  • Hello,

    the problem your having is Ur xml is no good

    when you set @strXML, you need to use an apostorphe (')

    with an attribute in an xml string the Value is wrapped in Quotes (")

    and the special characters in your string will screw up the parsing.

    Please change your string as I have shown below.

     

    set quoted_identifier on

    DECLARE @StrXml varchar(8000)

    DECLARe @Idoc int

    SET @StrXml = '<employee name="jon&apos;s dicosta &amp; Co"/>'

    EXEC Sp_Xml_PrepareDocument @idoc OUTPUT, @StrXml

    exec sp_xml_Removedocument @idoc

     

  • It worked

    Thanks for your reply

    Can you give me list of other special charatcers with its value ?

    Waiting for your reply

    Thanks

  • It is Very urgent

    If i write something in Word File & Insert Bullet Also

    & if i copied that in TextBox, user click on SAVE link

    I am passing XML to SP

    It gives error

    XML parsing error: An invalid character was found in text content

    '· Manish'

    . is actual Bullet

    now how can i solve this problem & what to do if User Paste any Character b/w 0 - 255

    Thanks in Advance

  • I got solution

    instead of setting Parameter as TEXT Datatype for XML Parameter in Stored Procedure, we have changed it to NTEXT & it worked

    TEXT datatype doesn't support Special Character while parsing with SP_XML_PREPAREDOCUMENT

  • it did not worked for me. I have datatype as varchar(8000) and sending XML data as follows:

Viewing 6 posts - 1 through 5 (of 5 total)

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