1 <?php 2 $string = <<<XML 3 <?xml version="1.0" encoding="utf-8" ?> 4 <returnsms> 5 <returnstatus>status</returnstatus> 6 <message>message</message> 7 <remainpoint> remainpoint</remainpoint> 8 <taskID>taskID</taskID> 9 <successCounts>successCounts</successCounts> 10 </returnsms> 11 XML; 12 13 // $xml = simplexml_load_string($string); 14 // print_r($xml); 15 16 17 //转换为simplexml对象 18 19 $xmlResult = simplexml_load_string($string); 20 21 //foreach循环遍历 22 23 foreach($xmlResult->children() as $childItem) { 24 25 //输出xml节点名称和值 26 $xml_l=array(); 27 28 } 29 30 print_r($xml_l); 31 32 ?>
在php项目中,返回一个xml文件。
请问,我怎么将xml中的<message>message</message>存放在变量或者数组中那。谢谢!