如何使用PHP XMLWriter添加更多元素?

时间:2017-07-26 10:12:51

标签: php xmlwriter

我的代码:

$writer = new XMLWriter();
$writer->openURI('data.xml');
$writer->startDocument('1.0','UTF-8');  
$writer->startElement("cont");
$writer->writeElement('product', $produto);  
$writer->writeElement('price', $preco); 
$writer->endDocument();
$writer->flush();

输出:

Product: CD
Price: 10,00

如何在不删除最后一个元素的情况下添加元素?

我希望这个xml返回。

Product: CD2
Price: 20,00
Product: CD
Price: 10,00
Product...

0 个答案:

没有答案