How to use XQuery for this XML

  • Thread starter Thread starter Sudip_inn
  • Start date Start date
S

Sudip_inn

Guest
This is my xml

<?xml version="1.0" encoding="utf-16"?>
<Root>
<string>EBITDA</string>
<string>Products Revenue</string>
</Root>





i used to count this way @cnt INT = @xmldata.value('count(/Root/SectionLiMap)', 'INT')

i tried this but got error

Msg 9438, Level 16, State 1, Line 1
XML parsing: line 2, character 6, text/xmldecl not at the beginning of input


declare @xmldata xml =N'
<?xml version="1.0" encoding="utf-16"?>
<Root>
<string>EBITDA</string>
<string>Products Revenue</string>
</Root>'

Declare @cnt INT = @xmldata.value('count(/Root/string)', 'INT')
print @cnt

How to parse with xquery. now this below code not working

SELECT @Lineitem = col.value('(LineItem/text())[1]','VARCHAR(MAX)')
FROM @xmldata.nodes('/Root/SectionLiMap[position() =
thanks

Continue reading...
 
Back
Top