I have XML like:
<?xml version="1.0" encoding="utf-16"?> <ExportProjectDetailsMessage xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Project"> <CPProjectId>7665699f-6772-424c-8b7b-405b9220a8e7</CPProjectId> </ExportProjectDetailsMessage>
I am trying to get CPProjectId as Uniqueidentifier using:
DECLARE @myDoc xml DECLARE @ProdID varchar(max) SET @myDoc = '<ExportProjectDetailsMessage xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Project"><CPProjectId>7665699f-6772-424c-8b7b-405b9220a8e7</CPProjectId></ExportProjectDetailsMessage>' SET @ProdID = @myDoc.value('(ExportProjectDetailsMessage/CPProjectId)[1]', 'varchar(max)' ) SELECT @ProdID
All I can get is NULL = / I tried many combinations on @ myDoc.value, but no results = /
How can I get the value from my XML?
Thanks!
- EDIT: Something I noticed when I remove a namespace declaration from XML, it works great! The problem is that I need these namespaces! = /
source share