I am trying to select text nodes of Lookup.Result element of the following xml document using XPath in Sql Server.
<Commands>
<Command id="1">
<Lookup.Result>Result.OK</Lookup.Result>
</Command>
</Commands>
I try the following query:
declare @xml xml
set @xml = '<Commands>
<Command id="1">
<Lookup.Result>Result.OK</Lookup.Result>
</Command>
</Commands>
'
select t.c.value('./Lookup.Result/text()[1]', 'varchar(20)')
from @xml.nodes('/Commands/Command') t(c)
but i get the following error: XQuery [value()]: Syntax error near 'Lookup'
How can I escape . (dot in Lookup.Result element tag name) in an XPath expression? Please, help find an elegant solution to this problem. Thank you in advance for your time.