yetti78
asked on
Shredding XML into SQL Server With Multiple Namespaces
Okay, have XML that contains both non-namespace and custom namespace elements. Trying to shred it into SQL Server 2008 Enterprise, and I've gone through this:
https://www.experts-exchange.com/questions/24897455/XML-parsing-line-27-character-86-unexpected-end-of-input.html
But I want to be able to work with both namespace and non-namespace elements:
-------------------------- ----
CREATE PROC [dbo].[listings_save]
(
@inputData XML
)
AS
SET NOCOUNT ON
;WITH _incomingData AS
(
SELECT
items.item.value('(@lID)[1 ]', 'INT') AS LID,
items.item.value('(title)[ 1]', 'VARCHAR(255)') AS title,
items.item.value('foo:stat usType[1]' , 'INT') AS statusType
FROM @inputInfo.nodes('declare namespace foo="http://www.fooinc.com"; /item') AS items(item)
)
-------------------------- -----
How can I get work with all elements equally to get them into the CTE above?
https://www.experts-exchange.com/questions/24897455/XML-parsing-line-27-character-86-unexpected-end-of-input.html
But I want to be able to work with both namespace and non-namespace elements:
--------------------------
CREATE PROC [dbo].[listings_save]
(
@inputData XML
)
AS
SET NOCOUNT ON
;WITH _incomingData AS
(
SELECT
items.item.value('(@lID)[1
items.item.value('(title)[
items.item.value('foo:stat
FROM @inputInfo.nodes('declare namespace foo="http://www.fooinc.com"; /item') AS items(item)
)
--------------------------
How can I get work with all elements equally to get them into the CTE above?
<item foo:lID="0" xmlns:foo="http://www.fooinc.com">
<title>An Item to Buy</title>
<foo:statusType>1</foo:statusType>
<foo:test>icle</foo:test>
<guid>12345</guid>
</item>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
brejk,
Well done. When you have a second, this is a new issue I'm having trouble with if you'd like to take a stab at. Thanks!!!
https://www.experts-exchange.com/questions/25031654/Performing-Multiple-Merges-in-SQL-Server-2008-Stored-Procedure-With-Shredded-XML.html
Well done. When you have a second, this is a new issue I'm having trouble with if you'd like to take a stab at. Thanks!!!
https://www.experts-exchange.com/questions/25031654/Performing-Multiple-Merges-in-SQL-Server-2008-Stored-Procedure-With-Shredded-XML.html
ASKER
Bravo!
Open in new window