如何从服务器响应(PHP)创建XML文件

如何从服务器响应(PHP)创建XML文件,php,xml,Php,Xml,我有一个使用PHP从服务器得到的响应,它以XML格式返回。不幸的是,我不能透露有问题的代码,因为它是针对客户的,但这里有一个简短的版本: // server request code here… $result = $soap>__doRequest($xmltosend,URL,$action,1); //the final part of the request process… // $result is the returned xml that is to be converte

我有一个使用
PHP
从服务器得到的响应,它以
XML
格式返回。不幸的是,我不能透露有问题的代码,因为它是针对客户的,但这里有一个简短的版本:

// server request code here…
$result = $soap>__doRequest($xmltosend,URL,$action,1); //the final part of the request process…
// $result is the returned xml that is to be converted into a separate file 
有没有什么方法可以将返回的
XML
生成一个新文件?如果您有任何问题,我将非常乐意回答


提前谢谢

DOMDocument
试试:

$doc = new DOMDocument();
$doc->loadXML($result);
$doc->save("/tmp/your-document.xml");

您可以在

中找到更多信息。您是否尝试过
文件内容('file.xml',$result)