xml - How to escape ">" character in postgres version 9.2 -
how make >
sign display in pg version 9.2 ? not want show >
.
query in postgresql
select xpath ('/behaviorreportingranges/behaviorreportingrange/range/text()', xmlparse(content '<behaviorreportingranges> <behaviorreportingrange> <range>> 3</range> </behaviorreportingrange> </behaviorreportingranges>'))
result in version 9.1:
{"> 3"} -- desired result
result in version 9.2.3:
"{"> 3"}" -- not desired result
any pointers please ?
thanks lot !
well, if create language plpythonu;
, can following:
create or replace function unescape(x varchar) returns varchar language plpythonu $$ xml.sax.saxutils import unescape return unescape(x) $$;
then, query can become:
select unescape( concat( ( xpath ('/behaviorreportingranges/behaviorreportingrange/range/text()', xmlparse(content '<behaviorreportingranges> <behaviorreportingrange> <range>> 3</range> </behaviorreportingrange> </behaviorreportingranges>')) )[1] ) );
you need add indexing select element array result of xpath, , concat convert xml string datatype.
you can apply unescape function directly -- resulting string formatted xml array.
Comments
Post a Comment