K
K
kill942015-11-30 00:08:28
SQL Server
kill94, 2015-11-30 00:08:28

How to parse xml?

how to parse xml?
for example, there is an xml variable with the line
declare @xml xml
set @xml ='file.txt 2817 parse
it to be
File name: file.txt
Size: 2817 bytes

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
skorpk, 2015-12-03
@skorpk

So this is not xml, but a regular varchar. And you can
declare @xml VARCHAR(50)
set @xml ='file.txt 2817'
SELECT substring(@xml,0,PATINDEX('% %',@xml)),substring(@xml,PATINDEX('% %',@xml),LEN(@xml))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question