PHP XML ignore whitespace

$xml_data = preg_replace("/>\s+</", "><", $xml_data);

Removes all the whitespace, tabs and newlines between the nodes from an XML file. A lot of PHP XML parsers tend to parse the white space, which can cause errors. Adding the function before the PHP XML data handler executes will prevent those issues from arising.