I have the following XML:
declare @xml xml = '
<DiscoverResponse xmlns="urn:schemas-microsoft-com:xml-analysis">
<return>
<root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset">
<row>
<xars:METADATA xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<Server>
<Name>myName</Name>
</Server>
</xars:METADATA>
</row>
</root>
</return>
</DiscoverResponse>'
And I have been able to parse up to the <row> tag with the following query
; WITH XMLNAMESPACES(
'urn:schemas-microsoft-com:xml-analysis' AS ns1,
'urn:schemas-microsoft-com:xml-analysis:rowset' AS ns2
)
select
t.x.value('ns2:Name[1]','varchar(100)') AS Name
from @xml.nodes('//ns1:DiscoverResponse/ns1:return/ns2:root/ns2:row') t(x)
I am stuck trying to figure out how to query past the <xars:METADATA> tag. That is, I have not been able successfully construct a namespace declaration and path specification to get to the <Server> node (I am trying to extract the Name of the Server). I am running afoul of the extra colon it seems.
Thanks in advance.
xarsis not declared at all... Where does this come from? Is the generation under your control? There are ways to query this, but it will be ugly and slow...