postgresqlHow can I get a value from a PostgreSQL XML column?
You can get a value from a PostgreSQL XML column using the xpath()
function.
Example code
SELECT xpath('/foo/bar/text()', xml_column)
FROM some_table;
Output example
┌───────────────────────┐
│ xpath │
├───────────────────────┤
│ {SomeValue} │
└───────────────────────┘
The code above uses the xpath()
function to get the value of the bar
node inside the foo
node of the xml_column
column.
Code explanation
xpath()
- a PostgreSQL function used to get a value from an XML column/foo/bar/text()
- an XPath expression used to specify the target nodexml_column
- the XML column from which the value is retrieved
Helpful links
More of Postgresql
- How do I use PostgreSQL ZonedDateTime to store date and time information?
- How can I troubleshoot zero damaged pages in PostgreSQL?
- How can Zalando use PostgreSQL to improve its software development?
- How can I use PostgreSQL with YAML?
- How do I use PostgreSQL and ZFS together?
- How do I parse XML data using PostgreSQL?
- How do I rename a table in PostgreSQL?
- How do I convert a string to lowercase in PostgreSQL?
- How do I use PostgreSQL aggregate functions?
- How can I use PostgreSQL and ZFS snapshots together?
See more codes...