Click here to Skip to main content
15,914,221 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
how can i validate xml node using xmlnamespace in storedprocedre

i have tried it
but its saying that ,
Incorrect syntax near the keyword 'IF'.


My code is :


ALTER PROCEDURE mch
@xmldoc XML
AS
BEGIN


;WITH XMLNAMESPACES('http://MCH.com/IF002/SD/MCGG/MCH' as ns0)


IF(SELECT @xmldoc.exist('//ns0:Brand_In/MC/MC1') AS BrandData)=0 BEGIN RAISERROR('MC1 not available in document',16,1); RETURN ; END


END

What I have tried:

how can i validate xml node using xmlnamespace in storedprocedre
Posted
Updated 11-Jul-16 0:14am

1 solution

The namespace declaration must be part of the select statement. Try this:
SQL
DECLARE @BrandData BIT

; WITH XMLNAMESPACES('http://MCH.com/IF002/SD/MCGG/MCH' as ns0)
SELECT @BrandData = @xmldoc.exist('//ns0:Brand_In/MC/MC1')

IF @BrandData=0 BEGIN RAISERROR('MC1 not available in document',16,1); RETURN ; END 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900