Read the whole response into a variable $xml.
Use strpos() to find the first blank line - in other words, a TCP end-of-line immediately followed by another TCP end-of-line: "\r\n\r\n". That indicates the end of the header.
With the position known, you can use substr() to chop off everything up to it, and keep the rest.
Alternative: when you're reading the response, don't bother to record any of it until you see your first \r\n\r\n; onle record what you read after seeing the blank line.