Hi, i am trying to parse an XML using OPENXML in a SQL server procedure.
The Xml was created by the DataSet.WriteXm l command in .Net.
Here is the XML and the Stored procedure
<?xml version="1.0" standalone="yes "?>
<BidData xmlns="http://tempuri.org/BidData.xsd">
<Bid>
<UserID>1</UserID>
<TagNumber>1234 </TagNumber>
<ImpersonatingU serID>1</ImpersonatingUs erID>
<Description>Te st-Sumit</Description>
<Status>1</Status>
<TrancheService TermId>2</TrancheServiceT ermId>
</Bid>
<BidFormFieldDa ta>
<BidFormFieldID >1</BidFormFieldID>
<BidFormFieldVa lue>1234</BidFormFieldVal ue>
</BidFormFieldDat a>
<BidFormFieldDa ta>
<BidFormFieldID >2</BidFormFieldID>
<BidFormFieldVa lue>4567</BidFormFieldVal ue>
</BidFormFieldDat a>
</BidData>
----------------------------------------------------------------------------
---------
CREATE PROCEDURE dbo.sp_XmlTest
(@InputXml Text,
@BidId INTEGER OUTPUT)
AS
DECLARE @hDoc int
exec sp_xml_prepared ocument @hDoc OUTPUT,@InputXm l
SELECT @BidId=UserID
FROM OPENXML (@hDoc,'/BidData/Bid',2)
WITH (UserID numeric(18,0))
EXEC sp_xml_removedo cument @hDoc
GO
----------------------------------------------------------------------------
------------------------------------
the problem i am having is that the XPATH does not find the UserID element
if my XML has the namespace attribute but works fine without it
(xmlns="http://tempuri.org/BidData.xsd"). Can you let me know what am i
missing here ?
The Xml was created by the DataSet.WriteXm l command in .Net.
Here is the XML and the Stored procedure
<?xml version="1.0" standalone="yes "?>
<BidData xmlns="http://tempuri.org/BidData.xsd">
<Bid>
<UserID>1</UserID>
<TagNumber>1234 </TagNumber>
<ImpersonatingU serID>1</ImpersonatingUs erID>
<Description>Te st-Sumit</Description>
<Status>1</Status>
<TrancheService TermId>2</TrancheServiceT ermId>
</Bid>
<BidFormFieldDa ta>
<BidFormFieldID >1</BidFormFieldID>
<BidFormFieldVa lue>1234</BidFormFieldVal ue>
</BidFormFieldDat a>
<BidFormFieldDa ta>
<BidFormFieldID >2</BidFormFieldID>
<BidFormFieldVa lue>4567</BidFormFieldVal ue>
</BidFormFieldDat a>
</BidData>
----------------------------------------------------------------------------
---------
CREATE PROCEDURE dbo.sp_XmlTest
(@InputXml Text,
@BidId INTEGER OUTPUT)
AS
DECLARE @hDoc int
exec sp_xml_prepared ocument @hDoc OUTPUT,@InputXm l
SELECT @BidId=UserID
FROM OPENXML (@hDoc,'/BidData/Bid',2)
WITH (UserID numeric(18,0))
EXEC sp_xml_removedo cument @hDoc
GO
----------------------------------------------------------------------------
------------------------------------
the problem i am having is that the XPATH does not find the UserID element
if my XML has the namespace attribute but works fine without it
(xmlns="http://tempuri.org/BidData.xsd"). Can you let me know what am i
missing here ?