Reputation: 3386
I have a piece of sql text which uses:
Cast ('< M>' + Replace(JobNote, ',', '< /M>< M>') + '< /M>' AS XML)
and when i execute it the error generated is:
XML parsing: line 1, character 23, illegal name character can someone tell me what should I do??
(please ignore the blankspace before M>
in < M>
)
Upvotes: 0
Views: 979
Reputation: 93694
The space in < M>
is what not allowing to cast the string as XML
remove the space like
select Cast ('<M>' + Replace(JobNote, ',', '</M>') + '</M>' AS XML)
then it will work fine.
And There are few special characters are invalid in XML
so it has to be replaced in JobNote
with the following.
& - &
< - <
> - >
" - "
' - '
select Cast ('<M>' + Replace(JobNote, ',', '</M>< M>') + '</M>' AS XML)
Upvotes: 1