CREATE TABLE xmltest ( id int, data xml ); INSERT INTO xmltest VALUES (1, 'one'); INSERT INTO xmltest VALUES (2, 'two'); INSERT INTO xmltest VALUES (3, '' SELECT * FROM xmltest; id | data ----+-------------------- 1 | one 2 | two (2 rows) SELECT xmlcomment('test'); xmlcomment ------------- (1 row) SELECT xmlcomment('-test'); xmlcomment -------------- (1 row) SELECT xmlcomment('test-'); ERROR: invalid XML comment SELECT xmlcomment('--test'); ERROR: invalid XML comment SELECT xmlcomment('te st'); xmlcomment -------------- (1 row) SELECT xmlconcat(xmlcomment('hello'), xmlelement(NAME qux, 'foo'), xmlcomment('world')); xmlconcat ---------------------------------------- foo (1 row) SELECT xmlconcat('hello', 'you'); xmlconcat ----------- helloyou (1 row) SELECT xmlconcat(1, 2); ERROR: argument of XMLCONCAT must be type xml, not type integer SELECT xmlconcat('bad', '' SELECT xmlelement(name element, xmlattributes (1 as one, 'deuce' as two), 'content'); xmlelement ------------------------------------------------ content (1 row) SELECT xmlelement(name element, xmlattributes ('unnamed and wrong')); ERROR: unnamed attribute value must be a column reference SELECT xmlelement(name element, xmlelement(name nested, 'stuff')); xmlelement ------------------------------------------- stuff (1 row) SELECT xmlelement(name employee, xmlforest(name, age, salary as pay)) FROM emp; xmlelement ---------------------------------------------------------------------- sharon251000 sam302000 bill201000 jeff23600 cim30400 linda19100 (6 rows) SELECT xmlelement(name wrong, 37); ERROR: argument of XMLELEMENT must be type xml, not type integer SELECT xmlparse(content 'abc'); xmlparse ---------- abc (1 row) SELECT xmlparse(content 'x'); xmlparse -------------- x (1 row) SELECT xmlparse(document 'abc'); ERROR: invalid XML document DETAIL: Start tag expected, '<' not found. SELECT xmlparse(document 'x'); xmlparse -------------- x (1 row) SELECT xmlpi(name foo); xmlpi --------- (1 row) SELECT xmlpi(name xmlstuff); ERROR: invalid XML processing instruction DETAIL: XML processing instruction target name cannot start with "xml". SELECT xmlpi(name foo, 'bar'); xmlpi ------------- (1 row) SELECT xmlpi(name foo, 'in?>valid'); ERROR: invalid XML processing instruction DETAIL: XML processing instruction cannot contain "?>". SELECT xmlpi(name foo, null); xmlpi ------- (1 row) SELECT xmlpi(name xmlstuff, null); ERROR: invalid XML processing instruction DETAIL: XML processing instruction target name cannot start with "xml". SELECT xmlpi(name foo, ' bar'); xmlpi ------------- (1 row) SELECT xmlroot(xml '', version no value, standalone no value); xmlroot ----------------------- (1 row) SELECT xmlroot(xml '', version '2.0'); xmlroot ----------------------- (1 row) SELECT xmlroot(xmlroot(xml '', version '1.0'), version '1.1', standalone no); xmlroot --------------------------------------- (1 row) SELECT xmlroot ( xmlelement ( name gazonk, xmlattributes ( 'val' AS name, 1 + 1 AS num ), xmlelement ( NAME qux, 'foo' ) ), version '1.0', standalone yes ); xmlroot ---------------------------------------------------- foo (1 row) SELECT xmlserialize(content data as character varying) FROM xmltest; data -------------------- one two (2 rows) -- Check mapping SQL identifier to XML name SELECT xmlpi(name ":::_xml_abc135.%-&_"); xmlpi ------------------------------------------------- (1 row) SELECT xmlpi(name "123"); xmlpi --------------- (1 row)