在我的站点中,我实现了以下功能:如果用户单击一个按钮,它将触发一个 PHP 函数,该函数生成一个 XML 文件(该 PHP 函数由 AJAX 调用)。一切运行良好,但我想改变一件事:我不想在服务器机器上创建 .XML 文件;相反,我希望提示用户在本地保存 .XML 文件。我怎么做?我的 PHP 脚本目前如下所示:
$xml = new DOMDocument("1.0", "UTF-8");
$rootElement = $xml->appendChild($xml->createElement("SomeNodeName"));
...
// the following doesn't really work - xml doesn't get formatted :)
$xml->formatOutput = true;
// this creates the actual file and places it on server. that's not what i need
$xml->save("MyXMLfile.xml");
感谢所有的帮助。