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 can I troubleshoot zero damaged pages in PostgreSQL?
- How do I use PostgreSQL's XMIN and XMAX features?
- How can I monitor PostgreSQL performance using Zabbix?
- How can I integrate PostgreSQL with Yii2?
- How can I use PostgreSQL with YAML?
- How do I use PostgreSQL's XMLTABLE to parse XML data?
- How do I use PostgreSQL UNION to combine the results of two queries?
- How do I decide whether to use PostgreSQL VARCHAR or TEXT data types?
- How do I use PostgreSQL with Qt?
- How can I retrieve data from PostgreSQL for yesterday's date?
See more codes...