As a preface: I cannot imagine this has not been asked before, but I have failed miserably at finding a solution...and I would think there is a simple solution and I am simply doing something completely wrong.
I have a simple index.php file that looks like so:
<?php
$data = file_get_contents('php://input');
echo "DATA : " . $data;
$xml = new SimpleXMLElement($data, 0, true);
echo "XML : " . $xml;
$RoundTrip = (string) $xml->RoundTrip;
$TransactionId = (string) $xml->TransactionId;
?>
The echo "DATA" shows:
<?xml version="1.0" encoding="utf-8"?><msg><head><Client>Test</Client><RoutingArea>811</RoutingArea><Source>MySRC</Source><Destination>BSRC</Destination><Version>2.27</Version><RoundTrip>ID=001088129291102</RoundTrip><TransactionId>12652b05-ceb9-11eb-a091-00505687f2ee</TransactionId><ServerId>03</ServerId></head><body><POdated>
...and the SimpleXMLElement is throwing an error:
PHP Warning: SimpleXMLElement::__construct(): I/O warning : failed to load external entity "<?xml version="1.0" encoding="utf-8"?><msg><head
As if the string is being read as URLencoded...but the initial output is not URLencoded.
My Goal is to: receive the XML doc from the request as a string and be able to parse it.