Skip to content

Instantly share code, notes, and snippets.

@62mkv
Created May 20, 2020 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 62mkv/e2e91e878b139fc4e80003b6c1dabf4e to your computer and use it in GitHub Desktop.
Save 62mkv/e2e91e878b139fc4e80003b6c1dabf4e to your computer and use it in GitHub Desktop.
How to use XPath against XML text fields with PostgreSQL
/* real-world example */
select xpath('/ns2:PrintData/Meta/Document/@id', xmlparse (document payload),
ARRAY[ARRAY['ns2', 'http://iopm.int.kn/iopm4xml/meta/v1.4']]) from request_history_step_payload rhsp
join request_history_step rhs on rhs.step_uuid = rhsp.step_uuid
where rhs.step_type = 'PRINTER_REQUEST' and rhs.started_at between '2020-05-19' and now()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment