I have an XML column that contains thousands of rows. Each row contains the xml representation of a metadata file.
How do I extract multiple xml fields from each row? I guess I need to use xpath (https://www.postgresql.org/docs/current/static/functions-xml.html), but the given examples are not enough for me to understand it.
Let's assume there's this in a row called "data" in the table "xml":
> <gmd:MD_Metadata xmlns:gmd="http://www.isotc211.org/2005/gmd"
> xmlns:gco="http://www.isotc211.org/2005/gco"
> xmlns:gml="http://www.opengis.net/gml"
> xmlns:xlink="http://www.w3.org/1999/xlink"
> xmlns:geonet="http://www.fao.org/geonetwork"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.isotc211.org/2005/gmd
> something.com/schemas/inspire/gmd/gmd.xsd">
> <gmd:contact>
> <gmd:CI_ResponsibleParty>
> <gmd:organisationName>
> <gco:CharacterString>Something</gco:CharacterString>
> </gmd:organisationName>
> <gmd:contactInfo>
> <gmd:CI_Contact>
> <gmd:address>
> <gmd:CI_Address>
> <gmd:electronicMailAddress>
> <gco:CharacterString>[email protected]</gco:CharacterString>
> </gmd:electronicMailAddress>
> </gmd:CI_Address>
> </gmd:address>
> </gmd:CI_Contact>
> </gmd:contactInfo>
> </gmd:CI_ResponsibleParty>
> </gmd:contact>
How do I get the organisationName and the electronicMailAddress for all rows in the xml column? What would the query look like as a select statement?