XML : XMLElement function Encoding XML <> to < and >

I want to build some xml starting with the inner XML and then adding outer XML. Here's a simplification of my code:

  DO  $$  DECLARE    v_xml           text;    cmd             text;  BEGIN    cmd := 'select xmlelement(name myelement, ''test'')';    EXECUTE cmd INTO v_xml;    v_xml := xmlelement(name parentXMl, v_xml);    RETURN v_xml;  END;  $$    

I would expect this code to return:

  <parentxml><myelement>test</myelement></parentxml>    

Instead it returns:

  <parentxml>&lt;myelement&gt;test&lt;/myelement&gt;</parentxml>    

How can I stop XMLElement() from encoding my XML to XML values?

No comments:

Post a Comment