【发布时间】:2010-12-15 02:32:03
【问题描述】:
$fp = fopen('data.txt', 'r');
$xml = new SimpleXMLElement('<allproperty></allproperty>');
while ($line = fgetcsv($fp)) {
if (count($line) < 4) continue; // skip lines that aren't full
$node = $xml->addChild('aproperty');
$node->addChild('postcode', $line[0]);
$node->addChild('price', $line[1]);
$node->addChild('imagefilename', $line[2]);
$node->addChild('visits', $line[3]);
}
echo $xml->saveXML();
我正在使用这个脚本将文本文件转换为 xml 文件,但我想将它输出到一个文件中,我该如何做这个 simpleXML,干杯
【问题讨论】:
标签: php xml simplexml xmlwriter