sql server - XML without a root element still valid? -


i found nice way split strings:

declare @x varchar(100)='a,b,c';  --this "normal" way splitxml(x) (select cast('<root><x>' + replace(@x,',','</x><x>') + '</x></root>' xml)) select splitxml.x, a.b.value('.','varchar(1)') splitxml cross apply splitxml.x.nodes('/root/x') a(b); 

then found same approach without "root" , thought not work, does...

--now same without "root" --this leads invalid xml, works without problems splitxml(x) (select cast('<x>' + replace(@x,',','</x><x>') + '</x>' xml)) select splitxml.x, a.b.value('.','varchar(1)') splitxml cross apply splitxml.x.nodes('/x') a(b) 

is xml in splitxml.x valid or invalid? xml need root-singleton?


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -