Do you need to insert this into a SQL Server table? If yes: what version of SQL Server?
You can simply simply drop this into SQL Server using XQuery and paste the data into the table. Use something like:
;WITH XMLNAMESPACES('http://schemas.xmlsoap.org/soap/envelope/' AS ns) SELECT @input.value('(/ns:Envelope/ns:Body/ns:Element1/ns:Element2/@day)[1]', 'varchar(50)') AS 'DayElement', node.el.value('(@name)[1]', 'varchar(50)') AS 'Name', node.el.value('(ns:Element4/@time)[1]', 'int') AS 'Time', node.el.value('(ns:Element4/ns:Element5/@amount)[1]', 'decimal(15,2)') AS 'Amount', node.el.value('(ns:Element4/ns:Element5/@price)[1]', 'decimal(15,2)') AS 'Price' FROM @input.nodes('/ns:Envelope/ns:Body/ns:Element1/ns:Element2/ns:Element3') AS node(el)
and this will give you the result:
Day Name Time Amount Price 2009-10-18 Joe 1 0.00 16.58 2009-10-18 Fred 5 0.00 15.41
Of course, you can use this to provide data to the INSERT INTO dbo.MyTable()..... and thus immediately save your data in a table
source share