If I take the following XML:
<security>
<user>user</user>
<password>pass </password>
</security>
and call the Trim() method on the InnerText of the password node, it Trims it properly, but If I modify the fragment to look like this:
<security>
<user>user</user>
<password>pass
I can’t get the Trim() method to work, pass with the spaces removed is return as pass (It has a single space at the end). I looked at the watch window and when I doubnle click the value, it shows it as:
"pass" & vbLf & ""
The String.Trim method never removes new line characters. It only removes spaces. If you want to remove all line feeds, you could simply do something like this:
But, that will remove any line feeds at the beginning or in the middle of the text. But, perhaps that is what you want, anyway.
Or, you can use Trim’s overload to pass an array of characters to remove (but it will only remove from the beginning and end, not the middle):