PHP submits XML as post, obtains XML, and finally parses XML
Submit XML as Post
Do a POST
$data = "<?xml version= ' 1.0 ' encoding= ' UTF-8 '?>
<TypeRsp>
<connect_id>1 </CONNECT_ID>
<MO_MESSAGE_ID>2</MO_MESSAGE_ID>
</TypeRsp> ";
$data = Array (' name ' => ' Dennis ', ' surname ' => ' Pallett ');
Create a new curl resource
$ch = Curl_init ();
Set URL and other appropriate options
curl_setopt ($ch, Curlopt_url, "http://localhost/handle_form.php");
curl_setopt ($ch, Curlopt_post, true);
curl_setopt ($ch, Curlopt_postfields, $data);
Grab URL, and print
curl_exec ($ch);
Get post to XML and parse
handle_form.php
$file _in = file_get_contents ("Php://input"); Receive post data
$xml = simplexml_load_string ($file _in);//convert post data to SimpleXML object
foreach ($xml->children () as $ Child) //Traverse all node data
{
echo $child->getname (). ": " . $child. "<br/>"; Print node name and node value
//if ($child->getname () = "from") //Pick up node to operate
//{
//echo "I Say". ": Get you!". "<br/>"; Operation node data
//}
}
exit;
Thank you for reading, I hope to help you, thank you for your support for this site!