For XML returns ansi equivalent for operators.

  • How do return the actual value (>, <, =)? using for xml.

  • I dont think for = there will be any problem.

    DECLARE @C CHAR(1)

    SET @C = '='

    SELECT 1   as TAG,

      NULL  as PARENT,

      @C  as [RESPONSE!1!SAMPLE!ELEMENT]

    FOR XML EXPLICIT  

    Also for other characters we may have to use CDATA

    Not sure but you can give it a try.

    Thanks

    george

     

     

  • Can you give an example?

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • Sorry Guys.  Here's an example:  The xml output returns the values in the operator column as ansi.  Thanks for your help.

    Create

    table #tmpTestXML (obja varchar(10), operator char (5), objb varchar(10))

    Insert into #tmpTestXML values (1, '>', 2)

    Insert into #tmpTestXML values (2, '=', 2)

    Insert into #tmpTestXML values (2, '<', 3)

    Select

    ObjA, operator, objb from #tmpTestXML for XML Auto

    Output:

    <

    _x0023_tmpTestXML ObjA="1" operator="&gt; " objb="2" />

    <

    _x0023_tmpTestXML ObjA="2" operator="= " objb="2" />

    <

    _x0023_tmpTestXML ObjA="2" operator="&lt; " objb="3" />

  • And what do you want the output to look like?

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • I would like it to return '>', the symbol.

  • So show the whole result...

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • > I would like it to return '>', the symbol.

    It can't. Not if it's returning well-formed XML. XML requires markup characters in text content to be escaped, so that the parser won't think they're markup characters. The only exception to that is CDATA, and you don't even want to think about going there.

    You need to learn more about how XML parsers and DOMs work. This isn't something that you can or should fix inside the database.

    Robert Rossney

    rbr@well.com

Viewing 8 posts - 1 through 7 (of 7 total)

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