将转换后的 XML 存储到 XML 文件中


storing the transformed xml into xml file

>我已经转换了XML,如何使用php将其(转换后的XML)保存在XML文件(data.xml)中

我的PHP文件是:

<?php
$xmlDoc = new DOMDocument('1.0');
$xmlDoc->formatOutput = true;
$xmlDoc->load("products.xml");
$xslDoc = new DomDocument;
$xslDoc->load("product.xsl");
$proc = new XSLTProcessor;
$proc->importStyleSheet($xslDoc);
$strxml= $proc->transformToXML($xmlDoc);
echo ($strxml);
?>

请参阅 http://php.net/fopen 和 http://php.net/fwrite

总之:

<?php
$fp = fopen('data.xml', 'wb');
fwrite($fp, $xml);
?>
可以使用

以下函数解析XML字符串。

$convertedXML = simplexml_load_string($strXml);

可以使用以下命令保存

$convertedXML->saveXML("member.xml"); 

干杯。