I receive an XML file from a web service and, and sometimes this XML comes with a namespace, and sometimes it doesn't.
When I have the XML contained in the @myDoc variable, the select returns null. But, if I remove the "xmlns" part, the select returns the value normally.
What am I doing wrong?
DECLARE @myDoc xml
DECLARE @CSTAT VARCHAR(MAX);
SET @myDoc = '<infProt Id="ID311140002329206" xmlns="some_namespace">
<cStat>100</cStat>
</infProt>'
SET @CSTAT = @myDoc.value('(/infProt/cStat)[1]', 'VARCHAR(MAX)' )
SELECT @CSTAT