I'm trying to select a value from a xml column field with the following query:
SELECT LTRIM(LocalData.value('(/root/questionphrase[@ln="nl"]/xhtml/p)[1]', 'nvarchar(max)'))
FROM Question
The structure of my xml:
<root>
<questionphrase ln="nl">
<xhtml>
<p>
Data I want to select</p>
</xhtml>
</questionphrase>
</root>
I'm getting back the expected values but they all start with 2 whitespaces. After some investigating it turns out there's a tab char(9)
and a line feed character char(10)
at the beginning of the string. Is there a generic way to strip these characters from the output without manually replacing them? I was hoping LTRIM and RTRIM would do the trick, but no luck so far.
Note: I only want to replace the characters in the beginning and the end of the string