A 3rd party APP delivers a XML message at a URL. I want to be able to read and operate with that message at WordPress.
I believe that SimpleXMLElement is the key, rather than creating a class. But many errors are returned based on what I put as a parameter.
add_action( 'rest_api_init', function () {
  register_rest_route( 'webhook', '/v1', array(
    'methods'  => 'POST',
    'callback' => 'myfunction',
  ));
});
function myfunction () {
    $mymessage = new SimpleXMLElement($xmlstr);
    $messageType = $mymessage->cgCallback[0]->existingField;
    echo $messageType ;
}
$mymessage = new SimpleXMLElement($xmlstr); -> Returns "Undefined variable: xmlstr"
$mymessage = new SimpleXMLElement($data); -> Returns "Uncaught TypeError: SimpleXMLElement::__construct() expects parameter 1 to be string"
$mymessage = new SimpleXMLElement($message); -> Returns "Uncaught Exception: String could not be parsed as XML"
