I'm outputting a huge string which is created by a WYSIWYG editor. The following is an example of an output that the editor makes. I'm trying to prevent all the spaces created by the  
's from the beginning and end (inside each tag), so that the tags tightly wrap the content. Rtrim and Ltrim don't work because they trim the whole string, not the tags inside it.
Here is an example of a string.
<div> Small amount of text, should be alot.</div>
<div>Small amount of text, should be alot. </div>
This will output something along the lines of the following (the div has been left in to show the extent of the spaces, but would be hidden on output.)
<div> Small amount of text, should be alot.</div>
<div>Small amount of text, should be alot. </div>
I would prefer this out output..
<div>Small amount of text, should be alot.</div>
<div>Small amount of text, should be alot.</div>
How can this be achieved?