<?PHP//the file is//$raw _post_data = file_get_contents (' php://input ');//file_put_contents (' A.txt ', $raw _post_data, File_ APPEND);//Master XML operation data First$data= <<<XML<?xml version= "1.0" encoding= "Utf-8"? ><cdr id= "1920150803154502-0" > <callid>8216</callid> <outer id= "/>" <TimeStart>20150803154311</TimeStart> <Type>OU</Type> <Route> ip</route> <CPN>338</CPN> <CDPN>053286677735</CDPN> <timeend>20150803154502 </TimeEnd> <Duration>96</Duration> <TrunkNumber>568116939</TrunkNumber> < Recording>20150803/338_053286677735_20150803-154326_8216</recording></cdr>XML;Echo' <pre> ';$xml _obj=simplexml_load_string($data);//Create a SimpleXML object//Get the name of the nodeEcho $xml _obj->getname (). ' <br> ';//Gets the element information that follows the nodeforeach($xml _obj->children () as $child) { $attribute= ' '; //gets the name of the child element $name=$child-GetName (); //Loop to get property information for child elements foreach($child->attributes () as $k=$v) { $prefix=Empty($attribute) ?$attribute:$attribute. ‘,‘; $attribute=$prefix. "{$k}:{$v}"; } $att=Empty($attribute) ? ': ' Property:$attribute"; Echo $name. ‘:‘ .$child.$att. ' <br> ';}Print_r($xml _obj);//Output XML?>
PHP Functions--"Parsing XML data"