xmltable() extracts a sequence of multi-valued elements from an XML document, and assembles a SQL table of those elements. A single call to xmltable() replaces a T-SQL loop performing multiple calls to xmlextract on each iteration. This function is invoked as a derived table (a parenthesized subquery specified in the from clause of another SQL query). Calling xmltable() is equivalent to executing a single xmlextract expression for each row of the table generated by xmltable().
xmltable() is a generalization of xmlextract. Both functions return data extracted from an XML document that is an argument in the function. The differences are:
xmlextract returns the data identified by a single XPath query.
xmltable() extracts the sequence, or row pattern, of the data identified by an XPath query, and extracts from each element of that sequence the data identified by a list of other XPath queries, the column patterns. It returns all the data in a SQL table.