I want to parse the @xml below and produce a table like:
declare @xml XML = '<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetInvoiceResponse xmlns="http://www.myCompany.com.au/gateway2/invoicemanagement">
<GetInvoiceResult>
<AccountNumber>54321</AccountNumber>
<InvoiceNumber>Inv10001</InvoiceNumber>
<Lines>
<InvoiceLine>
<Cost>5.86</Cost>
<Ean>Ean111</Ean>
<QuantitySupplied>1</QuantitySupplied>
</InvoiceLine>
<InvoiceLine>
<Cost>4.00</Cost>
<Ean>Ean222</Ean>
<QuantitySupplied>2</QuantitySupplied>
</InvoiceLine>
</Lines>
<TotalCost>9.86</TotalCost>
</GetInvoiceResult>
</GetInvoiceResponse>
</soap:Body>
</soap:Envelope>';
I want to parse the @xml and produce a table with header and lines.
+---------------+--------+------+-----------+
| InvoiceNumber | Ean | Cost | TotalCost |
+---------------+--------+------+-----------+
| Inv10001 | Ean111 | 5.86 | 9.86 |
| Inv10001 | Ean222 | 4.00 | 9.86 |
+---------------+--------+------+-----------+
