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
Post a Comment