Convert to string and trim before creating text nodes