What would be the best way of removing the leading and trailing whitespace of some given html without using explicit replace? Attached an example report with some HTML as an example, showing the spacing that I want to get rid of.

As you can see the purple cell holds the html, and the spacing above and below is what I want to remove, but if there is spacing within (multiple paragraphs for example) then I don't want to remove that spacing. Only the leading and trailing whitespace.
Any help greatly appreciated 