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 optionscurl_setopt ($ch, Curlopt_url, "http://localhost/handle_form.php"); curl_setopt ($ch, Curlopt_post,true); curl_setopt ($ch, Curlopt_postfields,$data);//grab URL, and printCurl_exec ($ch);
Get post comes 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 objectforeach($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 the node to operate//{//echo "I say". ": Get you!". "<br/>"; Manipulating node data//}}Exit;
PHP submits the XML as a post, gets the XML, and finally parses the XML