I'm trying to parse the following xml to get the first tag following the s:Body tag (in this case I'm looking for the string queryEE, in other messsages with the same Envelope/Body structure it will be different)
I began playing with it with something like this:
declare @text varchar(max)
set @text = N'
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<queryEE xmlns="http://xx.gob.gcaba.xx/">
<codeEE xmlns="">xxxx</codeEE>
</queryEE>
</s:Body>
</s:Envelope>'
declare @x xml
set @x = cast(@text as xml)
select @x.query('/s:Envelope')
But I get the error:
Msg 2229, Level 16, State 1, Line 16
XQuery [query()]: The name "s" does not denote a namespace.
Seems like I'm having troubles with the namespace stuff
When I try with select @x.query('/Envelope') I don't get any results at all
Thanks to the answers I got from @shnugo I could finally solve it with:
select @x.value('local-name((/*:Envelope/*:Body/*)[1])','nvarchar(100)')