How to remove Namespaces from XML tags when using FOR XML option WITH XMLNAMESPACES RRS feed

  • Question

  • Hello,

    i have a problem with xml formatting using SQL FOR XML structure.

    I have written SQL QUERY which generates XML  string like that:


    <asx:abap xmlns:asx="">
     <asx:values xmlns:asx="">
      <HEADER xmlns:asx="">
      <ITEM xmlns:asx="">
       <ZCTX_PLU_ITEM xmlns:asx="">
        <BASE_UNIT />


    SQL query uses option 


    ;WITH XMLNAMESPACES('' as asx)


    to add XML namespaces.

    Here is an example of SQL code, which formats XML string:


    ;WITH XMLNAMESPACES('' as asx)
    select (--abap
    	select (--values
    		FOR XML PATH('HEADER'), type),
    FOR XML PATH(''), root('ITEM'), type
    	FOR XML PATH('asx:values'), type ) 
    FOR XML PATH('asx:abap'), type

    But i do not need to add automatically  namespaces on the <ITEM/> and <ZCTX_PLU_ITEM/> tags. 

    Is any option to prevent adding namespaces to those tags?



    Monday, July 25, 2011 3:19 PM