I've tried a few solutions $xml = new SimpleXMLElement($_POST); This gives and error Fatal error: Uncaught exception 'Exception' with message 'SimpleXMLElement::__construct() expects parameter 1 to be string, array given' in C:\Inetpub\Sites\ACR\test.php:12 Stack trace: #0 C:\Inetpub\Sites\ACR\test.php(12): SimpleXMLElement->__construct(Array) #1 {main} thrown Fatal error: Call to undefined function simple_xml_loadstring() in Yet I know the function itself works because I have used it with curl when I have received a string back $reply = curl_exec($ch); $xml=simplexml_load_string($reply); So I assume my problem is my $_POST is a array and not a string. So my question is how to extract my xml from my post variable so I can read it correctly.
yeah $_POST is an array so to access the variabl you should put the name of the variable ... so something like this : $_POST["NAME OF THE VARIABLE SENT"];
I have no control over what is sent because it comes from a third party. The issue is with xml there is no variable name like there is in a form. Compare it to sending a post with curl curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlstr); If I try to read this post using a standard like foreach( $errors as $_POST => $value ){ if( !isset(${$key}) ){ // Don't clobber existing values ${$key} = $value; } if ($debug == 1) { echo "<P>$key => $value<P>\n"; //testing } } I would get an error message Warning: Invalid argument supplied for foreach()
$postText = trim(file_get_contents('php://input')); Read the article at http://snipplr.com/view/755/read-raw-post-data-useful-for-grabbing-xml-from-flash-xmlsocket/