The headline is xpath_array + UNNEST: it turns a column of XML documents into shredded rows, one per matching node, in a single SQL statement: ...