目前我有一个PHP文件,它读取发布的XML,然后将其转换/输出到JSON。该文件如下所示:
<?php
file_put_contents('myxmlfile.xml', file_get_contents('php://input'));
$xmldoc = new DOMDocument();
$xmldoc->load("myxmlfile.xml");
$xpathvar = new DOMXPath($xmldoc);
// Etc etc, for the purpose of my question seeing the rest isn't necessary
// After finishing the conversion I save the file as a JSON file.
file_put_contents('myjsonfile.json', $JSONContent);
?>
我收到的数据是XML格式。要转换它,我目前正在将其保存为XML文件,然后在创建新的DOMDocument()
并加载后立即将其保存。我的问题是,有什么方法可以切断中间人并加载XML直接使用file_get_contents()
?
理想情况下会是这样(不起作用):
$xmldoc->load(file_get_contents("php://input"));
如果有人能帮助我这样做,我真的很感激!
由于