Reputation:
Need to get the list of xml present inside an xml. This is what I have tried.
DECLARE @xml xml
SET @xml = '<a><b /><c><d /><d /><d /></c></a>';
DECLARE @i_xml xml = @xml.value('(/a/b/c)[1]', 'VARCHAR(100)')
Select @i_xml
But this gives me NULL
Upvotes: 0
Views: 31
Reputation: 13006
Based on your sample xml, c
and b
are on same child record of <a>
. value()
will give a scalar result, use query()
instead.
DECLARE @xml xml
SET @xml = '<a><b /><c><d /><d /><d /></c></a>';
DECLARE @i_xml xml = @xml.query('(//a/c/child::*)')
SELECT @i_xml
Upvotes: 1