In PHP, you can use the simplexml_load_string function to check if a string is a valid XML without displaying a warning.