c# - SQL Server XPath Query to Extract ArrayOfString -


how write xpath query return object that'll have array of string? can't seem value or string work.

<info>   <emailaddresses>     <string>email1</string>     <string>email2</string>     <string>email3</string>   </emailaddresses> </info>  select table.[object].value('(//info/emailaddresses)[1]','nvarchar(max)') 'emailaddresses' table ...  

leads cannot implicitly atomize or apply 'fn:data()' complex content elements, found type 'arrayofstring' within inferred type 'element(

select table.[object].query('(/info/emailaddresses)[1]') 'emailaddresses' table ...  

will return whole

  <emailaddresses>     <string>email1</string>     <string>email2</string>     <string>email3</string>   </emailaddresses> 

which makes odd parse in code since it'll have transferred object instead of list of string in c#

this example query returns list of emails xml

declare @x xml set @x =  '<info>   <emailaddresses>     <string>email1</string>     <string>email2</string>     <string>email3</string>   </emailaddresses> </info>'  select r.nref.value('.','nvarchar(max)') 'emailaddresses'  @x.nodes('/info/emailaddresses/*') r(nref) 

and can parse strings in resultset in way want in c# - put them in array of strings or ...


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -