Remove tags or attributes based on a whitelist from a snippet of well-formatted HTML text using PHP's DOM library.