replace preg_match with DOMDocument which seems more reliable