我想使用 PHP 从 XML 文件创建一些 XML,但我无法让它工作
XML 文件
<?xml version="1.0">
<streams>
<stream>test</stream>
</streams>
PHP的
<?php
header("Content-type: text/xml");
$xml = simplexml_load_file("t.xml");
$html = "<?xml version='1.0'>";
$html = $html . "<streams>";
foreach($xml->stream as $stream)
{
$html= $html . "<stream>";
$html = $html . "<![CDATA[" . $stream->title . "]]>";
$html= $html . "</stream>";
}
$html = $html . "</streams>";
echo $html;
?>
错误
Error: This page contains the following errors: error on line 2 at column 1:
Extra content at the end of the document Below is a rendering of the page up
to the first error.